libname data "C:\Documents and Settings\ejohnson\My Documents\MultilevelModels"; proc contents data=data.cognitive; run; data data; set data.cognitive; calorie = (trt=1); meat = (trt=2); milk = (trt=3); run; ** OLS regression **; proc glm data=data; model ravens = calorie meat milk / solution; run;quit; ** 3-level random intercept model **; ** these proc mixed take a bit to run; proc mixed data=data; class schoolid id; model ravens = calorie meat milk / solution; random intercept schoolid / subject=id; run; ** Add the other variables to the model for ravens score; proc mixed data=data; class schoolid id; model ravens = calorie meat milk age_at_time0 gender ses1 head_circ readtest writetest / solution; random intercept schoolid / subject=id; run; ** Linear time effect; ** Variable rn is the time in weeks; proc mixed data=data; class id; model ravens = rn calorie meat milk age_at_time0 gender ses1 head_circ readtest writetest / solution; random intercept / subject=id; run; ** random intercept and slope; proc mixed data=data; class id; model ravens = rn calorie meat milk age_at_time0 gender ses1 head_circ readtest writetest / solution; random intercept rn / subject=id type=un; * Note, these variance and covariance of the random effects are listed in the output; * according to the order listed in the random statement!; run;