options ls=85 nodate; data one; length drug $3; input treatment drug $ admin $ rep y; if drug="ins" then insulin=1; else insulin=0; cards; 1 aI 1 1 18 2 aI 2 1 23 3 aII 1 1 20 4 aII 2 1 17 5 ins b 1 30 6 ins s 1 33 1 aI 1 2 16 2 aI 2 2 19 3 aII 1 2 19 4 aII 2 2 15 5 ins b 2 28 6 ins s 2 36 1 aI 1 3 13 2 aI 2 3 17 3 aII 1 3 21 4 aII 2 3 20 5 ins b 3 26 6 ins s 3 30 run; /* Sums of squares for contrasts of interest generated directly using contrast statements */ proc glm; class treatment; model y=treatment; contrast "insulin-tablet" treatment -1 -1 -1 -1 2 2; contrast "Drug(with tablet)" treatment -1 -1 1 1 0 0; contrast "admin(with tablet)" treatment -1 1 -1 1 0 0; contrast "admin(with insulin)" treatment 0 0 0 0 -1 1; contrast "drug*admin(with tablet)" treatment -1 1 1 -1 0 0 ; estimate "insulin-tablet" treatment -1 -1 -1 -1 2 2/divisor=4; estimate "Drug(with tablet)" treatment -1 -1 1 1 0 0; estimate "admin(with tablet)" treatment -1 1 -1 1 0 0; estimate "admin(with insulin)" treatment 0 0 0 0 -1 1; estimate "drug*admin(with tablet)" treatment -1 1 1 -1 0 0 ; means treatment; run; /* Sums of squares for contrasts of interest generated using appropriate nesting of factors. */ proc glm; class drug admin insulin; model y=insulin drug(insulin) admin(insulin) drug*admin(insulin); lsmeans admin(insulin)/slice=insulin; run;