/*Kaz's SAS juku*/
/*www.estat.us*/
/*PROC MIXED and PROC REG COMPARISON*/
/*If I saw thes syntaxes before taking a HLM class, I would have understood the class a lot better*/
Data ABC;set sashelp.Prdsal3; /*This is a SAS default data set for a practice*/
run;
/*This is OLS*/
proc reg data=ABC ;
title "This is OLS";
model actual = predict;
run;
/*This is proc mixed, not estimating the random components for coefficients*/
/*You will get the same results as OLS above!!!!! Estimation method is different.*/
proc mixed data=ABC covtest noclprint;
title "One predictor as an fixed effect.";
class state;
model actual =predict/solution ddfm=bw;
run;
/*This is HLM*/
/*Note that I added a random statement to make the intercepts randomly varying by states*/
/*That is all!*/
proc mixed data=ABC covtest noclprint;
title "Random intercept model";
class state;
model actual =predict/solution ddfm=bw;
random intercept/sub=state;
run;
/*This is also HLM*/
/*both intercept and the coefficient are now random*/
proc mixed data=ABC covtest noclprint;
title "Intercept and the coefficient random";
class state;
model actual =predict/solution ddfm=bw;
random intercept/sub=state;
random predict/sub=state;
run;