5.4 Direct to long format in SPSS

As well as deriving the long format from the wide format in SPSS, we can also generate the long format directly. First, save temporary files, one for each wave, creating a wave variable and removing the wave prefix from the variables of interest:

get file "s:\bhps\spss\aindresp.sav"/keep=pid, ajbstat.
compute wave=1.
rename var ajbstat=jbstat.
save out = "c:\temp\tempa.sav".

get file "s:\bhps\spss\bindresp.sav"/keep=pid, bjbstat.
compute wave=2.
rename var bjbstat=jbstat.
save out = "c:\temp\tempb.sav".

. . .

get file "s:\bhps\spss\kindresp.sav"/keep=pid, kjbstat.
compute wave=11.
rename var kjbstat=jbstat.
save out = "c:\temp\tempk.sav".

Then simply add the temporary files together, sorting by pid and wave:

add files file = "c:\temp\tempa.sav"
         /file = "c:\temp\tempb.sav"
         /file = "c:\temp\tempc.sav"
         /file = "c:\temp\tempd.sav"
         /file = "c:\temp\tempe.sav"
         /file = "c:\temp\tempf.sav"
         /file = "c:\temp\tempg.sav"
         /file = "c:\temp\temph.sav"
         /file = "c:\temp\tempj.sav"
         /file = "c:\temp\tempk.sav".
sort cases by pid, wave.

One important difference: this format has records only for those waves for which the individual was in the sample.



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