# Grouping subject data for within-subject analysis in SPSS

I have over 30 subjects who each did the same task about 50 times. Each of these data point can be in condition a1 or a2 of variable A or condition b1, b2, b3 or b4. So for each subject, I have datapoints for a1b1, a2b2, etc.

I have three dependent variables (v1, v2, v3) for each data point.

I understand that this is a within-subject analysis, done through a repeated measure test.

But the way I understand it, if I want to compare a1 to a2, I have to make a column for a1 with each subject's average for a1, the same for a2, and compare those two columns. And I have to do it for each dependent variable, and then again for b1-b4. And if I want to study the interaction, I have to do the same for a1b1, a2b1, a1b2, and so on, again for each dependent variable. This seems quite impractical.

As of now, my data is set with a column for subject's ID, a column for A condition, a column for B condition, a column for each dependent variable v1 v2 and v3, and a row for each data point.

Is there a way to do the repeated measure analysis as follows?

"(average of v1 when A=a1 for each subject) vs (average of v2 when A=a2 for each subjet)"

• (note: as my knowledge of statistics and SPSS is quite limited, I understand this question might be lacking and/or not clear. please don't hesitate to suggest edits) Jan 22, 2014 at 23:43
• Would a 2-way repeated measures ANOVA for each DV work? statistics.laerd.com/spss-tutorials/…
– paul
Jan 23, 2014 at 0:14
• @paul Well that's actually exactly what I am trying to do. The issue is that I need to define two new columns for a1 and a2, then four more for b1 and b2, and then 8 more for each interaction of A and B. For each DV, so that's 42 columns. I'm surprised there is not a way to group all data using another variable (for example, having a column 'subject' with each subject's ID and group all data with the same subject's ID) Jan 23, 2014 at 18:06
• Sorry I don't understand. A 2-way ANOVA has 2 IVs (A & B). A is binary, one column, vals are 0 and 1 with labels a1 and a2. I don't see why you need two new columns for a1 and a2 If that's the case then there's a problem with your question, because a column should be one variable (A). You don't use a column per condition. B col has 4 values (again one col, nominal var, if ranked then ordinal var). You don't code the interaction as a column, it's calculated in the ANOVA (A*B). You may want to stick to 2 univariate ANOVAs. MANOVAs are harder to interpret, but you can try for v1 vs v2,
– paul
Jan 24, 2014 at 5:42
• @paul Well, I might be mistaken, but in the link above the example has 2 IVs and ends up having 6 columns to represent all interactions. Or is there something I'm missing? (thanks for the help by the way :)) Jan 24, 2014 at 8:11

I think you want to restructure the data, transforming it from the long to wide format. Here's some links to tutorials (googled):

Quoted from http://kb.iu.edu/data/bbqj.html:

"The long format uses multiple rows for each observation or participant:

ID  WEIGHT  CALORIES  TIME
1   200    3500        1
1   190    3300        2
1   180    3100        3
2   160    3000        1
2   150    2900        2
2   140    2800        3


The wide format uses one row for each observation or participant:

ID  weight1 weight2 weight3 calories1 calories2 calories3
1   200      190    180       3500     3300     3100
2   160      150    140       3000     2900     2800         "


The wizard is in Data > Restructure > Restructure selected cases into variables (second option).

Once the data is in this format you can run the two-way ANOVA for repeated measures (Analyze > General Linear Model > Repeated Measures...).