/***********************************************************************************/ /* Further Investigation of Significant Factor Effects: */ /* We use the Castle Bakery data found in Chapter 19 */ /* and used for the example from class. */ data bakery; input sales height width store; cards; 47 1 1 1 43 1 1 2 46 1 2 1 40 1 2 2 62 2 1 1 68 2 1 2 67 2 2 1 71 2 2 2 41 3 1 1 39 3 1 2 42 3 2 1 46 3 2 2 ; run; /* We saw earlier there was NO significant interaction between height and width: */ /* Investigating particular differences among factor level means */ /* The CL option to the LSMEANS statement produces (here, 95%) confidence */ /* intervals for each population factor level mean. */ PROC GLM DATA = bakery; CLASS height width; MODEL sales = height width height*width; LSMEANS height width / CL ALPHA = 0.05; run; /* ***************************************************************************** */ /* Contrasts: CIs and Hypothesis Tests */ /* Example: We want a 95% CI for the difference in the mean sales of the */ /* middle height and the mean sales of the other heights. */ /* The relevant contrast here is: -(1/2)mu_1-dot + mu_2-dot - (1/2)mu_3-dot */ /* The ESTIMATE statement defines the coefficients of the contrast (these must */ /* be in the proper order!) and gives the test statistic and P-value of the test */ /* for whether the contrast equals zero. */ /* The CLPARM option to the MODEL statement tells SAS to give a CI (by default, */ /* a 95% CI) for the contrast. */ PROC GLM DATA = bakery; CLASS height width; MODEL sales = height width height*width / CLPARM; LSMEANS height width; ESTIMATE 'MiddleVsOthers' height -0.5 1 -0.5; RUN; /* ***************************************************************************** */ /* Multiple Comparison Procedures */ /* In the MEANS statement, the CLDIFF option gives CIs for all pairwise height level */ /* mean differences, based on the Tukey procedure. The ALPHA=0.05 ensures that */ /* the family confidence level is 95%. SAS also provides an indication of which */ /* pairs of treatment means are judged to be significantly different, at the */ /* 0.05 family significance level, by the Tukey procedure. */ PROC GLM DATA = bakery; CLASS height width; MODEL sales = height width height*width; LSMEANS height width height*width; MEANS height / TUKEY ALPHA=0.05; /* Produces simpler output for Tukey test */ MEANS height / TUKEY ALPHA=0.05 CLDIFF; /* Produces Tukey CIs and testing results */ run; /* We could change TUKEY to SCHEFFE or BON to get the Scheffe or Bonferroni results, */ /* but if we're interested in all pairwise comparisons, these will not be as */ /* efficient as the Tukey procedure. */ /* ***************************************************************************** */