/* ratdiet.sas */ /* rat diet protein example */ options ls=72 ps=60; data rat; infile 'ratdiet.dat'; input level $ source $ gain; /* get the standard two-way ANOVA table */ proc glm data=rat; class level source; model gain = level source level*source / ss1 ss2; /* fit the cell means model */ proc glm data=rat; class level source; model gain = level*source / noint solution clparm ss1 ss2; /* estimate the simple effect and interaction contrasts */ /* level simple effects */ estimate 'hi vs low: beef' level*source 1 0 0 -1 0 0; estimate 'hi vs low: cereal' level*source 0 1 0 0 -1 0; estimate 'hi vs low: pork' level*source 0 0 1 0 0 -1; /* source simple effects */ estimate 'beef vs pork: hi' level*source 1 0 -1 0 0 0; estimate 'cereal vs meat: hi' level*source -1 2 -1 0 0 0 / divisor=2; estimate 'beef vs pork: low' level*source 0 0 0 1 0 -1; estimate 'cereal vs meat: low' level*source 0 0 0 -1 2 -1 / divisor=2; /* interactions */ estimate 'int1: beef vs pork' level*source 1 0 -1 -1 0 1; estimate 'int2: cereal vs meat' level*source -1 2 -1 1 -2 1 / divisor=2; /* get the single degree of freedom interaction sums of squares */ contrast 'int1: beef vs pork' level*source 1 0 -1 -1 0 1; contrast 'int2: cereal vs meat' level*source -1 2 -1 1 -2 1; /* get the ANOVA table sums of squares */ contrast 'level main' level*source 1 1 1 -1 -1 -1; contrast 'source main' level*source 1 0 -1 1 0 -1, level*source -1 2 -1 -1 2 -1; contrast 'interaction' level*source 1 0 -1 -1 0 1, level*source -1 2 -1 1 -2 1; /* estimate additional contrast */ estimate 'hi vs low: animal' level*source 1 0 1 -1 0 -1 / divisor=2; /* input cell means and create interaction plots */ data means; input level $ source $ mean; cards; high beef 100.0 high cereal 85.9 high pork 99.5 low beef 79.2 low cereal 83.9 low pork 78.7 ; proc plot data=means; plot mean*level=source; plot mean*source=level; title 'interaction plots'; run;