Reputation: 177
I run the following lines:
DATA abc;
INPUT AA BB CC DD EE;
CARDS;
...
;
RUN;
PROC GLM DATA = abc;
MODEL AA BB CC DD EE = / NOUNI;
REPEATED conditions 5 (1 2 3 4 5) / PRINTE;
MEANS / TUKEY ALPHA = 0.05;
RUN;
But the MEANS
statement works with class variables ("ERROR: Only class variables allowed in this effect." SAS says.). In turn I defined only responses (trials): MODEL AA BB CC DD EE = / NOUNI;
. Can anybody help me?
P.S.
(Basically my design is explained at the CrossValidated.)
Upvotes: 0
Views: 6823
Reputation: 6749
I'm fairly certain, based on my experience with SAS, that what you want isn't very easy to get at in SAS - though I believe it is possible. It's certainly easy to confirm by hand if you need to.
Consider the data from the link you gave, which I read into a SAS program...
DATA raw_lph;
INPUT idnum cntrl a b c d;
CARDS;
20 5.1 12.42 10.1 9.58 8.54
21 4.07 9.96 14.12 10.79 12.24
22 3.94 4.92 13.04 15.96 9.37
25 0.6 3.24 8.94 0.61 3.62
26 1.72 13.96 2.48 3.44 3.12
27 0.53 3.36 1.4 4 0.81
28 0.97 3.88 2.33 3.77 3.31
31 0.15 4.05 1.45 2.44 1.47
32 0.58 1.92 2.47 2.33 4.92
33 1.02 6.03 4.4 4.8 3.88
;
RUN;
To do a more traditional ANOVA on it, you need to transpose it, which I did.
DATA transposed_lph;
SET raw_lph;
RETAIN idnum;
ARRAY varnames[5] $ _TEMPORARY_ ('cntrl' 'a' 'b' 'c' 'd');
ARRAY steps[5] cntrl--d;
DO i=1 TO 5;
well=varnames[i];
pctlph=steps[i];
OUTPUT;
END;
KEEP idnum well pctlph;
RUN;
Now, there's two blocks below, one with the more traditional ANOVA format, and one set up to use the REPEATED statement.
PROC GLM DATA=transposed_lph;
CLASS well idnum;
MODEL pctlph = well idnum well(idnum);
LSMEANS well /ADJUST=TUKEY E=well(idnum) PDIFF=ALL;
QUIT;
PROC GLM DATA=raw_lph;
MODEL cntrl--d = /NOUNI;
REPEATED Well;
QUIT;
Dealing with repeated measures is all about handling variation within subjects, as opposed to between subjects. The first model fails because it has no error term, because we successfully accounted for ALL the variance in the model with the three terms. The terms are which well the blood is in, which subject it is, and the effect of the well nested within the idnum - or, in essence, the variance between each well per subject - aka within subject variation.
If you look at the output of the first set, you'll see that you end up with:
Source DF Type III SS Mean Square F p-value
well 4 134.5175200 33.6293800 . .
idnum 9 487.1931300 54.1325700 . .
well(idnum) 36 255.2066000 7.0890722 . .
Using the LSMEANS statement, I ask for the Tukey-adjusted means for well; the E=well(idnum) tells the system to use well(idnum) as the error term for these means. Now, look at the output from the second PROC GLM.
Source DF Type III SS Mean Square F Value Pr
Well 4 134.5175200 33.6293800 4.74 0.0035
Error(Well) 36 255.2066000 7.0890722
As you can see, the repeated measures identifies the same error statement for well. However, to my knowledge, you cannot get means from any of the modeling procedures in SAS without using a CLASS statement. So, one way to get around this is to restructure the model I did to try and "game the system". Alternatively, you can calculate the Tukey HSD by hand. There might be an R package that handles it better than SAS, too.
For what it's worth, I learned modeling on Minitab and it seemed to actually handle the modeling pretty well, so it might be worth looking at.
HTH!
Upvotes: 1