You can obtain multiple comparison tests in a repeated measures analysis by using the LSMEANS, SLICE, or LSMESTIMATE statements in several procedures. If the response is normally distributed, use PROC MIXED rather than PROC GLM. For other response distributions, use the GLIMMIX, GENMOD, or GEE procedure.
The following example from the PROC MIXED documentation uses the LSMEANS statement to compare means of a between-subjects factor (Gender) adjusting for (averaging over) a within-subjects factor (Age) and their interaction (Gender*Age). The SLICE statement is used to compare Genders at each Age and to compare Ages in each Gender.
data formixed(keep=Person Gender Age Y);
input Person Gender $ y1 y2 y3 y4;
Y=y1; Age=8; output;
Y=y2; Age=10; output;
Y=y3; Age=12; output;
Y=y4; Age=14; output;
datalines;
1 F 21.0 20.0 21.5 23.0
2 F 21.0 21.5 24.0 25.5
3 F 20.5 24.0 24.5 26.0
4 F 23.5 24.5 25.0 26.5
5 F 21.5 23.0 22.5 23.5
6 F 20.0 21.0 21.0 22.5
7 F 21.5 22.5 23.0 25.0
8 F 23.0 23.0 23.5 24.0
9 F 20.0 21.0 22.0 21.5
10 F 16.5 19.0 19.0 19.5
11 F 24.5 25.0 28.0 28.0
12 M 26.0 25.0 29.0 31.0
13 M 21.5 22.5 23.0 26.5
14 M 23.0 22.5 24.0 27.5
15 M 25.5 27.5 26.5 27.0
16 M 20.0 23.5 22.5 26.0
17 M 24.5 25.5 27.0 28.5
18 M 22.0 22.0 24.5 26.5
19 M 24.0 21.5 24.5 25.5
20 M 23.0 20.5 31.0 26.0
21 M 27.5 28.0 31.0 31.5
22 M 23.0 23.0 23.5 25.0
23 M 21.5 23.5 24.0 28.0
24 M 17.0 24.5 26.0 29.5
25 M 22.5 25.5 25.5 26.0
26 M 23.0 24.5 26.0 30.0
27 M 22.0 21.5 23.5 25.0
;
In PROC MIXED you can use the LSMEANS statement to compare Gender means adjusted for the other effects in the model – Age and Age*Gender. Use the SLICE statement to test for simple effects within an interaction.
proc mixed data=formixed;
class Person Gender age;
model y = Gender Age Gender*Age;
repeated Age / type=un subject=Person;
lsmeans Gender / pdiff;
slice Gender*Age / sliceby=Age;
slice Gender*Age / sliceby=Gender diff;
run;
The LSMEANS statement with the PDIFF option produced the following results which show that Females and Males on average differ by -2.32 and the difference is significant (p=0.0054).
Results from the first SLICE statement appear next. As Age increases, the difference between Males and Females becomes larger and more significant.
The DIFF option in the second SLICE statement produces pairwise Age differences for each level of the SLICEBY effect (Gender). For Females, the measurements are significantly different between Ages 8 and 12, 8 and 14, and 10 and 14 at alpha level 0.05.
For Males, the measurements are significantly different between Ages 8 and 12, 8 and 14, 10 and 12, 10 and 14, and 12 and 14 at alpha level 0.05.