PROC SORT Data = SASUSER.Adv04; BY currcoll; RUN;
PROC MEANS Data = SASUSER.Adv04; VAR satis; BY currcoll; RUN;
PROC MEANS Data = SASUSER.Adv04 MEAN STD MIN MAX SKEWNESS KURTOSIS;
VAR satis respect; RUN;
/*MLM w REML estimation, between-within df, unstructured covariance estimates*/
/* Model 1 with DV=Satis, Class=currcoll Unconditional Model */
PROC MIXED Data = SASUSER.Adv04 method=REML NOCLPRINT COVTEST;
CLASS currcoll; MODEL Satis = /SOLUTION ddfm=bw;
RANDOM INTERCEPT/SUB= currcoll type=un; RUN;
/*MLM w REML estimation, between-within df, unstructured covariance estimates*/
/* Model 2: DV=Satis, Class=currcoll Fixed Effect centered Predictor, RespectC */
PROC MIXED Data = SASUSER.Adv04 method=REML NOCLPRINT COVTEST;
CLASS currcoll; MODEL Satis = RespectC /SOLUTION ddfm=bw;
RANDOM INTERCEPT/SUB= currcoll type=un; RUN;
/*MLM w REML estimation, between-within df, unstructured covariance estimates*/
/* Model 3: DV=Satis, Class=currcoll Random Effect centered Predictor = RespectC */
PROC MIXED Data = SASUSER.Adv04 method=REML NOCLPRINT COVTEST;
CLASS currcoll; MODEL Satis = RespectC /SOLUTION ddfm=bw;
RANDOM INTERCEPT RespectC /SUB= currcoll type=un; RUN;
/* Calculate R2: create Y-hat for M2 and correlate with actual Y = Satisfaction */
/* Using Fixed Effect Intercept, 3.683 & RespectC Slope parameter, .5176 */
/* from model 2 (with Random Intercept and Respect predictor) calculated: */
/* Y_hat_M2 = 3.683 + .5176 * RespectC; RUN; QUIT; */
/* Use computed Y_hat_M2 now in data file, calculate R (y, Y_hat_M2) & square */
PROC CORR Data = SASUSER.Adv04; VAR Satis Y_hat_M2; RUN; QUIT;