1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 /* grapefruit2.sas (2018 version) */
74 title "Oneway ANOVA with repeated measures: Covariance Structure Approach";
75 title2 'Grapefruit data (Applied linear statistical models, 5th ed., Prob 27.6)';
76
77 data grape1;
78 infile '/folders/myfolders/441s18/Lecture/grapefruit1.data.txt' firstobs=2;
79 input store sales1-sales3;
NOTE: The infile '/folders/myfolders/441s18/Lecture/grapefruit1.data.txt' is:
Filename=/folders/myfolders/441s18/Lecture/grapefruit1.data.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=March 08, 2018 11:06:28,
File Size (bytes)=522
NOTE: 8 records were read from the infile '/folders/myfolders/441s18/Lecture/grapefruit1.data.txt'.
The minimum record length was 56.
The maximum record length was 56.
NOTE: The data set WORK.GRAPE1 has 8 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
80 proc print data=grape1;
81 run;
NOTE: There were 8 observations read from the data set WORK.GRAPE1.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.09 seconds
cpu time 0.09 seconds
82
83 data grape2; /* This data set will have 3n cases. */
84 set grape1;
85 price = 1; sales = sales1; output; /* Output creates a new case. */
86 price = 2; sales = sales2; output;
87 price = 3; sales = sales3; output;
88 /* Would keep store price sales; */
89
NOTE: There were 8 observations read from the data set WORK.GRAPE1.
NOTE: The data set WORK.GRAPE2 has 24 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
90 proc print data=grape2;
91 title3 'Data set with one case per observation';
92 run;
NOTE: There were 24 observations read from the data set WORK.GRAPE2.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.09 seconds
cpu time 0.10 seconds
93
94 /* It's better to use arrays */
95
96 data grape3;
97 set grape1;
98 array s{3} sales1-sales3;
99 do j = 1 to 3;
100 price = j; sales = s{j}; output;
101 end;
102 drop j sales1-sales3;
103
NOTE: There were 8 observations read from the data set WORK.GRAPE1.
NOTE: The data set WORK.GRAPE3 has 24 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
104 proc print data=grape3;
105 run;
NOTE: There were 24 observations read from the data set WORK.GRAPE3.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
106
107 proc mixed data=grape3;
108 title3 'Proc mixed with unknown covariance structure and lsmeans';
109 title4 'Compare F = 29.66, p = 0.0008';
110 class price;
111 model sales = price;
112 repeated / type=un subject=store r;
113 lsmeans price / pdiff tdiff adjust = bon;
114 /* Gives exactly pairwise matched t-tests in this case. */
115
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.25 seconds
cpu time 0.23 seconds
116 proc mixed data=grape3;
117 title3 'Proc mixed with compound symmetry cov. structure and contrasts';
118 title4 'Compare F = 49.35, p < 0.0001';
119 class price;
120 model sales = price;
121 contrast '1vs2' price 1 -1 0;
122 contrast '1vs3' price 1 0 -1;
123 contrast '2vs3' price 0 1 -1;
124 repeated / type=cs subject=store r;
125
126
127
128 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
141