/* Several missing cells--will study this later */ data a; input teacher method $ diff; datalines; 1 a 10 1 a 7 1 b 4 1 c . 2 a 6 2 b . 2 c 13 3 a 11 3 b 5 3 c 16 4 a . 4 b 7 4 b 8 4 c . 5 a 6 5 b 3 5 c . ; /* Only Teacher 2 Method b is misssing */ data b; input teacher method $ diff; label teacher='Teacher' method='Method'; datalines; 1 a 10 1 a 7 1 b 4 1 c 9 2 a 6 2 b . 2 c 13 3 a 11 3 b 8.5 3 c 16 4 a 6 4 b 4 4 b 5 4 c 8 5 a 6 5 b 3 5 c 6 ; run; *Look at table of means; proc tabulate data=b; class teacher method; var diff; table teacher,method*diff=''*mean=''; title 'Mean Improvement'; run; title; /* Create imputed data sets */ proc mi data=b nimpute=5 out=outmi; class teacher method; var teacher method diff; monotone reg(diff=teacher method); run; proc sql; select * from outmi; quit; /* This generates a simpler data structure than most input data sets to mianalyze */ proc glm data=outmi; class teacher method; model diff=teacher method teacher*method; lsmeans method/out=outlsmean; by _imputation_; run; /* This is an update to the above, using the ODS output system */ proc glm data=outmi; class teacher method; model diff=teacher method teacher*method; lsmeans method/stderr; ods output LSMeans=outlsmean; by _imputation_; run; proc sql; select * from outlsmean; quit; proc sort data=outlsmean; by method; run; /* Analysis for Method a and Method c is superfluous since no observations were imputed for these factor levels */ proc mianalyze data=outlsmean; by method; modeleffects lsmean; stderr stderr; run; /* Create imputed data sets for data set with additional missing values */ proc mi data=a nimpute=5 out=outmi; class teacher method; var teacher method diff; monotone reg(diff=teacher method); run; proc sql; select * from outmi; quit; /* This generates a simpler data structure than most input data sets to mianalyze */ proc glm data=outmi; class teacher method; model diff=teacher method teacher*method; lsmeans method/stderr; ods output LSMeans=outlsmean; by _imputation_; run; proc sql; select * from outlsmean; quit; proc sort data=outlsmean; by method; run; /* Analysis for Method a and Method c is superfluous since no observations were imputed for these factor levels */ proc mianalyze data=outlsmean; by method; modeleffects lsmean; stderr stderr; run;