%newsas(simple); title 'Testing Simple Effects in a 2x3 Design'; data Two; Input A $ B $ @; Do Subject = 1 to 8; Input Y @; Output; End; datalines; A1 B1 15 23 20 17 21 16 14 19 A1 B2 16 11 11 18 14 18 19 14 A1 B3 9 12 16 24 7 10 11 10 A2 B1 32 25 18 28 30 22 17 32 A2 B2 28 6 11 15 9 15 2 27 A2 B3 13 14 13 11 3 4 6 6 ; /*---------------------------------------------------* | Do the anova, with contrasts for simple effects | *---------------------------------------------------*/ proc glm data=Two; class A B; model Y = A B A*B / ss3; /* Simple effects for factor A: The contrast values for A */ /* specify A1-A2; those for A*B indicate which level of B*/ contrast 'A at B1' A 1 -1 A*B 1 0 0 -1 0 0; contrast 'A at B2' A 1 -1 A*B 0 1 0 0 -1 0; contrast 'A at B3' A 1 -1 A*B 0 0 1 0 0 -1; /* Simple effects for factor B */ /* Note that each test for B involves two contrasts */ contrast 'B at A1' B 1 -1 0 A*B 1 -1 0 0 0 0, B 1 0 -1 A*B 1 0 -1 0 0 0; contrast 'B at A2' B 1 -1 0 A*B 0 0 0 1 -1 0, B 1 0 -1 A*B 0 0 0 1 0 -1; run; /*---------------------------------------------------* | Simple effects using the SLICE option (SAS 6.11+) | *---------------------------------------------------*/ %version(6.11); proc glm; class A B; model Y = A|B; lsmeans A*B / slice=(A B); title2 'Using LSMEANS A*B / slice=(A B)'; run; /* Another way to get the SS */ %macro ignore; proc sort data=two; by A; proc glm; by A; /* repeat for A1, A2 */ class B; model Y = B; title2 'Getting SS B @ A1, A2 with BY statement -- IGNORE F TESTS'; run; %mend;