/* grapefruit1.sas */ title "Oneway ANOVA with repeated measures"; title2 'Grapefruit data (Applied linear statistical models, 5th ed., Prob 27.6)'; data grape1; infile '/home/u1407221/441s24/data/grapefruit1.data.txt' firstobs=2; input store sales1-sales3; label sales1 = 'Sales at Price 1' sales2 = 'Sales at Price 2' sales3 = 'Sales at Price 3'; /* Pairwise differences */ d12 = sales1-sales2; d13 = sales1-sales3; d23=sales2-sales3; proc means n mean stddev maxdec=3; var sales1-sales3; run; proc reg plots=none data=grape1; title3 'Test H0: mu1=mu2=mu3 with proc reg'; model d12 d13 = ; Price: mtest intercept=0; run; /* Linear combinations of response variables can be specified within proc reg rather than in the data step. Secify an equivalent null hypothesis, too. */ quit; /* For some reason, this is needed to make ods select work. */ ods select MultStat; proc reg plots=none data=grape1; title3 'Specifying linear combinations within proc reg'; model sales1 sales2 sales3 = ; Price: mtest intercept=0, sales1-sales2, sales2-sales3; run; proc glm data=grape1; title3 'Test H0: mu1=mu2=mu3 with proc glm'; model sales1-sales3 = ; repeated price / short summary mean; run; /* Could have done ods select MultStat -- no need for a quit this time. */ /* Note the Greenhouse-Geisser and Huynh-Feldt corrections for departures from "sphericity." Sphericity means equal variances of the differences. */ proc means mean t probt maxdec=3 data=grape1; title3 'Pairwise matched t-tests'; var d12 d13 d23; run; quit;