/* SAS Analysis of a Two-Factor Study (Case II: Interaction Present) */ /* We examine the Melon data used for the example from class. */ data melon; input FUNG $ CONCEN PERCENT; cards; B 100 0 B 100 0 B 100 33 B 100 0 B 100 0 B 1000 100 B 1000 40 B 1000 75 B 1000 100 B 1000 60 T 100 0 T 100 0 T 100 0 T 100 20 T 100 0 T 1000 20 T 1000 20 T 1000 0 T 1000 0 T 1000 40 C 100 0 C 100 0 C 100 0 C 100 0 C 100 0 C 1000 0 C 1000 0 C 1000 0 C 1000 50 C 1000 80 ; run; PROC GLM data = melon; CLASS FUNG CONCEN; MODEL PERCENT = FUNG CONCEN FUNG*CONCEN; run; /* We see that a significant FUNG*CONCEN interaction is present (P-value=0.0163). */ /* **************************************************************** */ /* Tukey simultaneous CIs and hypothesis tests */ /* The following is a fairly ugly way to get Tukey CIs and tests about each */ /* pair of treatment means. It defines a new variable (FUNGCONCEN), with a */ /* level for each A-B combination (for each cell). */ DATA new; SET melon; if FUNG='B' and CONCEN = 100 then FUNGCONCEN=11; if FUNG='C' and CONCEN = 100 then FUNGCONCEN=21; if FUNG='T' and CONCEN = 100 then FUNGCONCEN=31; if FUNG='B' and CONCEN = 1000 then FUNGCONCEN=12; if FUNG='C' and CONCEN = 1000 then FUNGCONCEN=22; if FUNG='T' and CONCEN = 1000 then FUNGCONCEN=32; run; PROC GLM data = new; CLASS FUNGCONCEN; MODEL PERCENT = FUNGCONCEN; MEANS FUNGCONCEN / TUKEY ALPHA=0.05; /* Produces simpler output for Tukey test */ MEANS FUNGCONCEN / TUKEY ALPHA=0.05 CLDIFF; /* Produces Tukey CIs and testing results */ run; /* This is a simpler way to get the Tukey CIs and test results about each */ /* pair of treatment means, but the output may be more difficult to interpret? */ PROC GLM data = melon; CLASS FUNG CONCEN; MODEL PERCENT = FUNG CONCEN FUNG*CONCEN; LSMEANS FUNG*CONCEN / pdiff CL ADJUST=TUKEY; run; /* ******************************************************************* */ /* Estimating and Testing about Constrasts in the Presence of Interaction */ PROC GLM data = melon; CLASS FUNG CONCEN; MODEL PERCENT = FUNG CONCEN FUNG*CONCEN / CLPARM; LSMEANS FUNG CONCEN FUNG*CONCEN; /* This is our example from class: Is the difference between fungicides */ /* B and C the same regardless of the concentration? */ ESTIMATE 'ExampleFromClass' FUNG*CONCEN 1 -1 -1 1 0 0; /* The different combinations are B100, B1000, C100, C1000, T100, T1000 */ /* This can be seen by looking at the "class level information'. */ /* This will affect how we specify the interaction effects of interest. */ /* Remember to write out the contrast in terms of the FACTOR EFFECTS when */ /* specifying the coefficients that go in the ESTIMATE statement. */ /* How about comparing Fungicides B and C when concentration is 100? */ ESTIMATE 'BvsC, Conc=100' FUNG 1 -1 0 CONCEN 0 0 FUNG*CONCEN 1 0 -1 0 0 0; run;