Proc mixed

Hello all,

I am a wee bit confused about the random statement in PROC MIXED, I thought maybe you can clarify it for me in simple words.

Let's for the illustration say I have an outcome variable Y, and a treatment variable X, getting:

1 - New intervention
0 - Control (or placebo in drugs)

I have n subjects, and each subject can get the treatment in 1 to 3 places in his/her body.

If I write a SAS PROC MIXED procedure like this:

PROC MIXED data = ....;
CLASS SubjectID, Treatment;
MODEL Y = Treatment;

what is the difference between:

1) RANDOM SubjectID;
2) RANDOM intercept / subject = SubjectID;
3) RANDOM intercept Treatment / subject = SubjectID;

and when do I use each one ?

thanks !
Since no one is answering, I'm going to say what I think. Feel free to correct me.

In model 1, I think it treats only subject as a random effect. I haven't seen this kind of model used before.

Model 2 uses the by-subject random intercept, which is needed when there is more than one observation per subject - this means different subjects have different overall responses. EDIT - I just read that if the subject variable is numeric and data is sorted on the variable in advance, it does not have to be declared, although I'm going to keep declaring it because I find it useful.

Model 3 finds the random slopes of treatment, which is needed if there is more than one observation for each unique combination of subject and treatment. This means that subjects vary in the nature of their response around the treatment effect. I've read that even if we assume random slopes variation that isn't present, the model is still usually ok. I would say you would go with the (maximal) model 3 in most cases, but if the model fails to converge or looks weird, go back to model 2. There are other ways of simplifying the random effects structure, but I'm not sure how to do them in SAS.
Last edited:


Cookie Scientist
I think models 1 and 2 are equivalent, but that is really just a guess. I didn't know that model 1 was valid syntax in PROC MIXED.