options pageno=1; data lscmb; input square row column trt \$ yield; datalines; 1 1 1 b 41 1 1 2 c 25 1 1 3 a 15 1 2 1 a 20 1 2 2 b 32 1 2 3 c 24 1 3 1 c 22 1 3 2 a 12 1 3 3 b 21 2 1 1 c 27 2 1 2 b 28 2 1 3 a 3 2 2 1 a 4 2 2 2 c 17 2 2 3 b 9 2 3 1 b 22 2 3 2 a 4 2 3 3 c 17 3 1 1 b 43 3 1 2 c 27 3 1 3 a 17 3 2 1 a 22 3 2 2 b 34 3 2 3 c 26 3 3 1 c 24 3 3 2 a 14 3 3 3 b 23 ;; proc print; title 'printout of data'; run; proc sort; by square; *Comment The previous statements are needed to do the ANOVA for each individual square; run; proc anova; by square; classes row column trt; model yield=row column trt; title 'anova of each individual square'; run; proc anova; classes square row column trt; model yield=square row(square) column(square) trt square*trt; means trt/lsd; means square*trt; *Comment Note that there is no LSD command since SAS will not calculate the LSD values for interactions. SAS only calculates LSD values for the main effects; title 'anova combined across squares assuming square and trt are fixed effects'; run; proc anova; classes square row column trt; model yield=square row(square) column(square) trt square*trt; test h=trt e=square*trt; *Comment The previous statement is needed since square is a random effect and treatment is a fixed effect. Squre*trt is the denominator of the F-test to test treatment; means trt/lsd e=square*trt; means square*trt; *Comment Note that there is no LSD command since SAS will not calculate the LSD values for interactions. SAS only calculates LSD values for the main effects; title 'anova combined across squares assuming square random and trt fixed'; run;