fruit bat
| |

PROC MIXED: More errors with repeated measures

Since the last few posts detailed errors in repeated measures with PROC GLM , I thought I should acknowledge that people seem to struggle just as much with PROC MIXED.

Forgetting data needs to be multiple rows

This is one of the first points of confusion for students. When you do a PROC MIXED, you need multiple records for each person. So, thinking back to my previous example with three time points, with PROC MIXED, and two options for treatment, my dataset needs to look like this:

SubjectExamTreatmentScore
1PreTalk43
1PostTalk46
1FollowTalk45
2PreDrug39

With GLM, you’d have 3 variables, named Pre, Post and Follow, for example (you *did* read the last post, right?). In PROC MIXED, your dataset has to be structured so that you have one variable, in this case, named “exam”, and it takes on one of three possible values.

Let’s start with the simplest case. I’d like to know, just like before, if there was a change from pre to post-test and if it was maintained at follow-up. In other words, my question is, “Was there a difference between the pretest and post-test and a difference between pretest and follow-up six months later?” I am not particularly interested in the post-test/ followup difference as such. Here is one way to code it:

Proc mixed data = example ;
class subject exam;
model score = exam ;
random subject ;
contrast “pre vs post” exam 1 -1 0 ;
contrast “pre vs follow” exam 1 0 -1 ;


The PROC GLM code from this post will give you the exact same results as the code above, but only if you have your data structured so that you have three variables instead of three records for each person.

I have a lot to say about CONTRAST statements, which I love, and random effects, about which I am neutral, and nested effects, that are not relevant to this example but could be. However, I am trying to not work past 9 pm and it’s already an hour later so … until next time.

Also, if you’re at SAS Global Forum, be sure to meet up and say “Hey!”

This is my day job …

Check it out. I make games that teach math, including, of course, statistics. Play AzTech: Meet the Maya – the only statistics game with Honduran fruit bats.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *