/* This example shows the analyses for the RBD */ /* using the wheat data example we looked at in class */ /* Entering the data and defining the variables: */ data wheatdata; input variety $ block yield; cards; A 1 31.0 A 2 39.5 A 3 30.5 A 4 35.5 A 5 37.0 B 1 28.0 B 2 34.0 B 3 24.5 B 4 31.5 B 5 31.5 C 1 25.5 C 2 31.0 C 3 25.0 C 4 33.0 C 5 29.5 ; run; /*******************************************************************/ /* What if we ignored the blocks and just did a one-way CRD ANOVA? */ PROC GLM data=wheatdata; CLASS variety; MODEL yield = variety; RUN; /* The effect of variety is not significant at the 5% level (p-value = .0590). */ /* This is NOT the best way to analyze these data!!!! */ /********************************************************************************/ /* Here we treat the experiment as a Randomized Block Design (RBD). */ /* PROC GLM will do a standard ANOVA for a RBD. */ /* We specify that block and variety are factors with a CLASS statement. */ /* The model statement specifies that yield is the response */ /* and block and variety are the two factors. */ /* We also include a RANDOM statement so SAS knows the block effect is random. */ PROC GLM data=wheatdata; CLASS block variety; MODEL yield = variety block; RANDOM block; RUN; /* Note that there are significant effects among treatments */ /* (F statistic = 27.34, P-value = .0003). */ /* This implies that the mean yield is significantly different */ /* for the different varieties of wheat. */ /* There is also significant variation among blocks */ /* (F statistic = 20.68, P-value = .0003). */ /* This may or may not be of interest. */ /* Note that SAS also gives the Expected Mean Squares for this design */ /* which helps us make sure we're using the right test statistic. */ /**********************************************************************************/ /* Question: Is Variety A superior to the others? */ /* We can again answer this question with an ESTIMATE statement about a contrast. */ PROC GLM data=wheatdata; CLASS block variety; MODEL yield = variety block; RANDOM block; ESTIMATE 'A vs Other Varieties' variety 2 -1 -1 / divisor=2; MEANS variety; RUN; /* Yes, clearly there is strong evidence (t = 7.28) that variety A has a superior */ /* mean yield to the others. */