5.3 Moving from long to wide in SPSS

It is sometimes necessary to move in the opposite direction (indeed, this happens quite often when you start with spell data).

In recent versions of SPSS, we can use the new CASESTOVARS command:

get file 'm:\multilong.sav'.

casestovars
  /id=pid
  /index=wave
  /sep="".

In older versions this strategy was necessary: To make a `long' vector for each variable, and in each record copy the appropriate value into it. Then you collapse/aggregate across individuals.

get file 'm:\multilong.sav'.
vector jbstat(11) /w(11).

compute jbstat(wave) = jbstat.
compute w(wave) = w.

aggregate out = * /break=pid
 /jbstat1 to jbstat11 = first(jbstat1 to jbstat11)
 /w1 to w11 = first(w1 to w11).

Compare the data you now have with that in the original file (multi.sav). Apart from having jbstat3 instead of cjbstat they should be the same.



Subsections

© Brendan T. Halpin (e-mail), GNU Free Documentation Licence