/* --------------------------------------------------- FILE: mixed02.sas DATA: See File hlmo2.sas for a description of these data and for their analysis using random effects in GLM PURPOSE: Illustration of a repeated measures analysis with random effects using PROC MIXED ----------------------------------------------------- */ DATA education; INPUT Treatment School Class Baseline Time1 Time2; DATALINES; 0 1 1 22.4 63.0 56.1 0 1 2 58.0 65.4 57.7 0 1 3 50.3 63.7 81.3 0 1 4 64.9 77.0 69.5 0 2 1 51.0 56.5 77.0 0 2 2 58.8 63.0 52.3 0 2 3 62.4 57.7 79.3 0 2 4 56.2 58.3 53.3 0 3 1 17.4 25.1 65.1 0 3 2 32.7 37.8 38.9 0 3 3 14.2 29.3 44.6 0 3 4 43.0 43.6 47.4 0 4 1 55.1 85.3 66.5 0 4 2 62.0 69.4 74.1 0 4 3 62.6 69.0 64.7 0 4 4 60.1 41.7 68.3 0 5 1 61.6 71.5 52.1 0 5 2 35.8 43.8 64.4 0 5 3 48.6 73.0 76.8 0 5 4 50.4 70.9 51.5 1 1 1 48.0 51.0 65.4 1 1 2 41.2 72.8 79.4 1 1 3 35.2 53.1 55.2 1 1 4 20.1 64.7 68.9 1 2 1 39.6 65.9 68.5 1 2 2 43.0 71.1 87.0 1 2 3 67.1 66.1 92.0 1 2 4 33.9 67.3 72.4 1 3 1 51.1 69.5 77.1 1 3 2 46.1 75.4 68.4 1 3 3 63.5 75.6 78.6 1 3 4 46.3 58.8 81.6 1 4 1 50.8 60.4 71.9 1 4 2 47.7 67.8 78.8 1 4 3 46.4 59.9 66.9 1 4 4 54.2 84.2 87.9 1 5 1 50.7 82.5 65.1 1 5 2 59.0 88.1 83.7 1 5 3 80.5 97.8 94.3 1 5 4 45.5 93.4 87.8 ; RUN; * - Create a new, stacked data set. This is necessary for input to PROC MIXED First, create a varible to denote each observation in the data set; DATA EdSTacked; SET Education; ObsNum = _N_; RUN; * - Now stack the data. The new dependent variable will be Score and the variable Time will be added. Each observation now has two rows in the data set; DATA EdStacked; SET EdStacked; Time=1; Score=Time1; Output; Time=2; Score=Time2; Output; DROP Time1 Time2; RUN; * - fit the same model as is file hlm02.sas; PROC MIXED DATA=EdStacked METHOD=reml; CLASS Treatment School; MODEL score = Baseline Treatment Time; RANDOM School(Treatment); REPEATED /SUBJECT=obsnum R RCORR TYPE=CS; RUN; * - test whether there is an interaction of Treatment * Time; PROC MIXED DATA=EdStacked METHOD=reml; CLASS Treatment School; MODEL score = Baseline Treatment Time Treatment*Time; RANDOM School(Treatment); REPEATED /SUBJECT=obsnum R RCORR TYPE=CS; RUN;