OPTIONS LINESIZE=80;
TITLE1 'Simple ANOVA with Multiple Mean Comparisons';
TITLE2 'Response variable: Strength ';
TITLE3 'Treatment : Cotton';
TITLE4 'Levels of treatment are 15, 20, 25, 30 and 35';
DATA FIBER;
INPUT COTTON STRENGTH @@;
/* @@ means a loop in reading input variable sequence */
CARDS;
15 7 15 7 15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7 35 10 35 11 35 15 35 11
;
RUN;
/* Print the original data set */
PROC PRINT;
RUN;
/* Analysis of Variance (ANOVA) */
PROC ANOVA;
CLASSES COTTON;
/* Dependent = Effects */
MODEL STRENGTH=COTTON;
MEANS COTTON / DUNCAN SNK;
MEANS COTTON / LSD TUKEY CLDIFF;
/* MEANS */
/* = Means of dependent variables for any effect, i.e., cotton */
/* DUNCAN */
/* = Duncan’s multiple-range test on all main effect means */
/* SNK */
/* = Student-Newman-Keuls multiple range test on all main effect means */
/* LSD */
/* = Fisher’s least-significant difference, i.e., paired t-test */
/* TUKEY */
/* = Tukey’s studentized range test on all main effect means */
/* CLDIFF */
/* = Calc. C.I. for all pairwise differences between means */
RUN;
/* Post-comparison of ANOVA method to GLM method */
TITLE1 'GLM APPROACH TO THE SAME PROBLEM';
PROC GLM;
CLASSES COTTON;
MODEL STRENGTH=COTTON;
MEANS COTTON / DUNCAN SNK LSD TUKEY;
/* Contrast = T.H. */
CONTRAST 'C30 vs. C35' COTTON 0 0 0 -1 1;
CONTRAST 'C15 and C25 vs. C30 and C35' COTTON 1 0 1 -1 -1;
CONTRAST 'C15 vs. C25' COTTON 1 0 -1 0 0;
CONTRAST 'C15, C25, C30 and C35 vs. C20' COTTON -1 4 -1 -1 -1;
RUN;
|