Reputation: 55
I want to reshape my long format data into a wide format. First I aggregated the data for later analysis, then I used the restructure command, with Subject_Nr as identifier variable and Switch_Type as index. My dependent variables are Reaction times and accuracy. I'd like to restructure the data so that every row is one Subject (in the long version, one row is one trial) so that I can use a within subject design. However, I keep running into the problem that at the end of the procedure, SPSS shows me the error message that sets from the original data will still be in used in the restructured data. I should use the "Use sets" dialogue. When I use this dialogue and select only the newly created variables, my dataset is empty. I am kind of desperate at this moment, because I spent already several hours to fix this issue without success. Has anyone a clue what I am doing wrong?
this is how the data looks like after the restructuring. as you can see, it is still in the long format and not in the wide format
here is some syntax:
SORT CASES BY Subj_Nr Swicht_Type.
CASESTOVARS
/ID=Subj_Nr
/INDEX=Swicht_Type
/GROUPBY=INDEX.
Upvotes: 2
Views: 3762
Reputation: 2929
If Swicht_Type
is an index within ID=Subj_Nr
then you would need Swicht_Type
to be unique within each Subj_Nr
(which doesn't seem to be the case with the data you present going by the print screen). And if that is not the cases then you would receive an error suggesting so.
Perhaps the two demonstrations (the first setup to fail deliberately) may shed some light to how the CASESTOVARS
command works and help you to revise you code or setup accordingly.
DATA LIST LIST / Dim1 (A1) Month (F1.0) Measure (F8.0).
BEGIN DATA.
A 1 50
A 2 40
A 3 20
A 1 56
A 2 86
A 1 45
B 2 68
B 3 58
B 1 57
END DATA.
DATASET NAME DSRaw.
SORT CASES BY Dim1 .
COMPUTE Month2=Month.
CASESTOVARS /ID=Dim1 /AUTOFIX=NO /INDEX=Month.
Which results in an error due to repeat of Month 1 in case row number 4.
If however you do in fact have unique index values within IDs then CASESTOVARS
works as expected:
DATA LIST LIST / Dim1 (A1) Month (F1.0) Measure (F8.0).
BEGIN DATA.
A 1 50
A 2 40
A 3 20
B 2 68
B 3 58
B 1 57
END DATA.
DATASET NAME DSRaw.
SORT CASES BY Dim1 .
COMPUTE Month2=Month.
CASESTOVARS /ID=Dim1 /AUTOFIX=NO /INDEX=Month.
Which gives you this:
Upvotes: 3