OPTION LS=76 NOCENTER; DATA ex9_1;INPUT drug p1 p2 p3 p4; plot=1;Y=p1;output;plot=2;Y=p2;output; plot=3;Y=p3;output;plot=4;Y=p4;output; CARDS; 1 56 48 66 62 2 83 78 94 93 3 80 72 83 85 ; PROC PRINT;VAR drug plot y; TITLE 'Print all the data for Ex9.1'; PROC GLM;CLASS drug plot; MODEL y=drug plot; TITLE 'Example 9.1, both factors are in model'; PROC GLM; CLASS drug plot; MODEL y=plot;TITLE 'Example 9.1, only plot in model'; PROC GLM; CLASS drug plot; MODEL y=drug;TITLE 'Example 9.1, only drug in model'; DATA unbalced;SET ex9_1; IF plot=1 and drug=1 THEN DELETE; PROC PRINT DATA=unbalced; TITLE 'One datum in Example 9.1 is deleted'; PROC GLM DATA=unbalced;CLASS drug plot; MODEL y=drug plot; TITLE 'Incomplete data for Example 9.1, model = drug plot'; PROC GLM DATA=unbalced;CLASS drug plot; MODEL y=plot drug; TITLE 'Incomplete data for Example 9.1, model = plot grug'; PROC GLM DATA=unbalced; CLASS drug plot; MODEL y=plot;TITLE 'Incomplete data for Example 9.1, only plot in model'; PROC GLM DATA=unbalced; CLASS drug plot; MODEL y=drug;TITLE 'Incomplete data for Example 9.1, only drug in model'; /* Data for two way with replicates */ DATA fruit;INPUT variety pestcide r1 r2; y=r1;output;y=r2;output; cards; 1 1 49 39 1 2 50 55 1 3 43 38 1 4 53 48 2 1 55 41 2 2 67 58 2 3 53 42 2 4 85 73 3 1 66 68 3 2 85 92 3 3 69 62 3 4 85 99 ; PROC PRINT;VAR variety pestcide y; TITLE 'Print all the data for fruit variety and pesticide'; PROC GLM;CLASS variety pestcide; MODEL y=variety pestcide variety*pestcide; TITLE 'Two way ANOVA with replicate'; MEANS variety/DUNCAN ALPHA=0.01; TITLE 'Duncan Multiple comaprisons for the main effects'; MEANS pestcide/DUNCAN ALPHA=0.01; PROC SORT DATA=fruit;BY variety pestcide; PROC MEANS NOPRINT;VAR y;OUTPUT OUT=forgraph MEAN=mu;BY variety pestcide; PROC PRINT DATA=forgraph; PROC PLOT DATA=forgraph; PLOT mu*pestcide=variety; /* To plot many curves on the same graph */ TITLE 'Plot of the means for the fruit data'; DATA interact;SET fruit; /* Multiple comparsions when interaction exists */ combined=10*variety+pestcide; PROC GLM;CLASS combined; MODEL y=combined; MEANS combined/DUNCAN ALPHA=0.01; TITLE 'Duncan Multiple comaprisons for the interaction'; /* Estimation of linear combinations of the means */ PROC GLM DATA=fruit;CLASS variety pestcide; MODEL y=variety pestcide variety*pestcide; CONTRAST 'Variety 1 vs 2' variety 1 -1 0/E; /* output is with the next estimate */ CONTRAST 'Variety 1 vs 2' variety 0.5 -0.5 0/E; /* E = usual MSE (vs others such as E3= Type III SS) */ TITLE 'Contrast (testing) between variety 1 and variert 2'; ESTIMATE 'pesticide 1+2 vs 3+4' pestcide 1 1 -1 -1/ E; ESTIMATE 'pest Av(1+2) - Av(3+4)' pestcide 0.5 0.5 -0.5 -0.5/ E; TITLE 'Estimate pesticide (1+2) - (3+4)';