This page is adapted from the SPSS AnswerNet. We are grateful to SPSS for permission to use provide their information to adapt and distribute this page from our web site.
I have a data set which contains one variable for each of three teachers for each case, called TEACH1, TEACH2 and TEACH3. I would like to restructure my data so that each teacher variable is on a separate case; in other words, so that there are three times as many cases as there are presently. Each teacher variable would now be represented by the variable TEACH, so that the three original variables aren’t differentiated.
You can restructure your data in several steps. By the way, this job is useful is you have multiple response data that are long
string variables which are not easily autorecoded or recoded.
The first step is to save a system file which contains only one of the three
teacher variables. You should also save a variable
which uniquely identifies the cases, so we can match pertinent information back to this case later. Do this for each of the three teacher variables.
In this example, let’s call the identifier variable ID. When you save each of
the system files, use the RENAME subcommand to
rename the teacher variables to the single variable TEACH. In the example below, FILE.SAV is the original system file, containing the variables TEACH1, TEACH2 and TEACH3.
GET file='file.sav'.SAVE outfile='temp1.sav'/keep=id teach1/rename(teach1=teach). SAVE outfile='temp2.sav'/keep=id teach2/rename(teach2=teach). SAVE outfile='temp3.sav'/keep=id teach1/rename(teach3=teach).
Now add these files together:
ADD FILES file='temp1.sav'/file='temp2.sav'/file='temp3.sav' /by id.
Now we have a file with three cases for each of the original
cases. We can match this file to the original system file using
the TABLE subcommand to match each occurrence of an ID value to in the new file to the unique occurrence of that ID value in the original file:
MATCH FILES file=*/table='file.sav'/drop teach1 teach2 teach3 /by id.