options pageno=1;
data nomiss;
INPUT Trt $ Rep Yield;
datalines;
A 1 9
B 1 11
C 1 3
D 1 7
A 2 8
B 2 13
C 2 5
D 2 10
A 3 7
B 3 12
C 3 8
D 3 4
;;
proc print;
title 'Printout of RCBD Data with No Missing Data';
run;
proc anova;
classes REP TRT;
model yield=rep TRT;
means TRT/lsd;
title 'ANOVA for RCBD with No Missing Data';
run;
data rcbdmiss;
INPUT Trt $ Rep Yield;
datalines;
A 1 9
B 1 11
C 1 3
D 1 7
A 2 8
B 2 13
C 2 .
D 2 10
A 3 7
B 3 12
C 3 8
D 3 4
;;
*Comment: Note that missing data is replaced with a period;
proc print;
title 'Printout of RCBD Data with One Missing Value';
run;
proc glm;
*Comment: The PROC GLM statement (general linear models) must be used when you have missing
data. The PROC ANOVA statement will not work;
*Note: The results Sum of Squares calculated in this ANOVA will be slightly different from
those in your notes since the PROC GLM method was used.;
classes rep trt;
model yield=rep trt;
lsmeans trt/pdiff;
*Comment: Since there is a missing value, we must ask for least square means to be calculated
instead of traditional means. This is done by using the LSMEANS statement instead of the
MEANS statement.
*Comment: The PDIFF statement requests t-tests between each pair of treatments so mean
separation can be performed. The PDIFF statement only works under PROC GLM.;
Title 'ANOVA for a RCBD with One Missing Value';
run;