I have a single data file in SPSS that is organized as such:
Project (Unique) | Student 1 Name | Student 2 Name | Student 3 Name |
---|---|---|---|
Project A | Barry B. | Roger W. | Frank L. |
Project B | Rebecca M. | Harry J. | Sam E. |
Project C | Kit B. | MISSING | MISSING |
I want to create a new table that gives each student their own row (and also lists the project they are affiliated with). Please notice the "MISSING" entries are omitted from the table:
Project | Student |
---|---|
Project A | Barry B. |
Project A | Roger W. |
Project A | Frank L. |
Project B | Rebecca M. |
Project B | Harry J. |
Project B | Sam E. |
Project C | Kit B. |
Please help!
I have done quite a bit of googling and watched various YouTube videos on joining, merging, concatenating, and appending. But it seems like I am trying to do something different and I can't pin down what this process is called.
CodePudding user response:
You need the varstocases
function to restructure your data from wide to long format. Like this:
varstocases /make Student from student1 student2 student3/index=studentN(student).
The resulting data structure will be as you described, plus the studentN
column will have the old student number column labels.