Site hosted by Angelfire.com: Build your free website today!

/* data taken from "The SAS System for Linear Models" */

/* A balanced factorial experiment consists of all possible combinations of levels of two or more */

/* factors.  Factorial experiments are used to investigate not only overall differences between */

/* levels of each factor (main effects), but also how levels of one factor affect the response variable */

/* across levels of another factor (interactions).  Consider the following example.  Suppose that 3 seed */

/* growth promoting methods (METHOD) are applied to seeds from each of five varieties (VARIETY) of turf */

/* grass.  Six pots are planted with seed from each METHODxVARIETY combination.  The resulting 90 pots are */

/* randomly placed in a uniform growth chamber and the dry matter yields (YIELD) are measured after */

/* clipping at the end of 4 weeks. */

 

data grasses;

   input method $ variety y1 y2 y3 y4 y5 y6 ;

   y1=y1/10; y2=y2/10; y3=y3/10; y4=y4/10; y5=y5/10; y6=y6/10;

   cards;

   A 1 221 241 191 221 251 181

   A 2 271 151 206 286 151 246

   A 3 223 258 228 283 213 183

   A 4 198 283 268 273 268 268

   A 5 200 170 240 225 280 225

   B 1 135 145 115  60 270 180

   B 2 169 174 104 194 119 154

   B 3 157 102 167 197 182 122

   B 4 151  65 171  76 136 211

   B 5 218 228 188 213 163 143

   C 1 190 220 200 145 190 160

   C 2 200 220 255 165 180 175

   C 3 164 144 214 199 104 214

   C 4 245 160 110  75 145 155

   C 5 118 143 213  63  78 138

   ;

 

   data fctorial;  set grasses;  drop y1-y6;

   yield=y1; output;

   yield=y2; output;

   yield=y3; output;

   yield=y4; output;

   yield=y5; output;

   yield=y6; output;

   run;

proc print data=fctorial ;

run ;

/* sort data by method and variety */

proc sort data=fctorial ;

  by method variety ;

/* calculate the means for each treatment level combination */

proc means data=fctorial noprint ;

   by method variety ;

   output out=factmean mean=yldmean ;

run ;

proc print data=factmean ;

run ;

/* create a simple interaction plot */

proc gplot data=factmean ;

  plot yldmean*variety = method ;

  symbol i = join ;

run ;

/* run the 2-way analysis of variance */

proc glm data=fctorial ;

  class method variety ;

  model yield = method variety method*variety ;

run ;

 

   quit ;