Programming the statistical procedures from SAS

Two within subject factors, repeated measures ANOVA

Occasional Contributor
Posts: 15

Two within subject factors, repeated measures ANOVA

[ Edited ]


I am stuck to conduct two-way repeated measures ANOVA with two within-subject factors (Treatment and Time).

This data is just an example, but in this study 5 subjects join a study session three times. In each session, they are assigned one of the three kinds of test food (treatment) and their appetite is measured at 0, 15 and 30 minute points after the test food consumption. 

Please find the excel file attached.


I would like to examine the treatment effect, time effect and interaction effect on appetite score, as well as at which time point the appetite score significantly differs between treatments (if there is a significant effect of treatment).


It would be really helpful if you could provide me with code that I can examine these. I want to know the code for normal (?) proc GLM procedure with two within subject factors, but also want to compare the result with that of proc MIXED repeated growth curve model (considering Time as continuous variable).


Thank you in advance,






Occasional Contributor
Posts: 15

Re: PROC GLM repeated measures (one class, two models)

Posted in reply to madpumpkinpie


proc glm;
     classes group;
     model Y1-Y12=group / nouni;
     repeated trt 3, time 4;

Hi again,

For the second question(, there is no factor that is analogous to "group" (between subject factor). There are just two within-subject factors. How should I modify this code?



Posts: 404

Re: Two within subject factors, repeated measures ANOVA

Posted in reply to madpumpkinpie

I moved the post from to keep threads tidy.


I would not use the GLM procedure. I think in terms of mixed models, and the model for this study could be constructed as a split-plot design, with whole plots (sessions) in blocks (subjects) with repeated measures. This format would allow you to accommodate the order of assignment of food treatments to sessions, as well as the temporal correlation among the three measurement times.


Maybe TIME would work well with a regression model, but there are only 3 levels and there's not much you can do other than a linear relationship. Maybe that would be appropriate for these data, maybe not.


For mixed models in SAS, SAS for Mixed Models, 2nd ed is an invaluable resource; an updated version ( SAS® for Mixed Models: An Introduction) is supposed to be released soon. If you run mixed models, you will benefit from reading it. At a more advanced level, Generalized Linear Mixed Models: Modern Concepts, Methods and Applications is also invaluable.

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation