1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;NOTE: ODS statements in the SAS Studio environment may disable some output features.7374 /* pain1.sas (2018 version) */75 title 'Multivariate repeated measures analysis of the pain data';7677 /* Read data from an old .xls spreadsheet */78 proc import datafile="/folders/myfolders/441s18/Lecture/Pain.xls"79 out=ouch0 dbms=xls replace;80 getnames=yes;NOTE: The import data set has 10 observations and 7 variables.NOTE: WORK.OUCH0 data set was successfully created.NOTE: PROCEDURE IMPORT used (Total process time):real time 0.02 secondscpu time 0.02 seconds81 proc print;8283 /* Dose 1 Dose 2 Dose 384 ------ ----- ------85 Drug 1 Drug1Dose1 Drug1Dose2 Drug1Dose386 Drug 2 Drug2Dose1 Drug2Dose2 Drug2Dose3 */8788 /* Computing sum and contrast variables in the data step */NOTE: There were 10 observations read from the data set WORK.OUCH0.NOTE: PROCEDURE PRINT used (Total process time):real time 0.10 secondscpu time 0.10 seconds89 data ouch1;90 set ouch0;91 /* Pairwise differences */92 d12 = Drug1Dose1-Drug1Dose2; d13 = Drug1Dose1-Drug1Dose3;93 d14 = Drug1Dose1-Drug2Dose1; d15 = Drug1Dose1-Drug2Dose2;94 d16 = Drug1Dose1-Drug2Dose3;95 d23 = Drug1Dose2-Drug1Dose3; d24 = Drug1Dose2-Drug2Dose1;96 d25 = Drug1Dose2-Drug2Dose2; d26 = Drug1Dose2-Drug2Dose3;97 d34 = Drug1Dose3-Drug2Dose1; d35 = Drug1Dose3-Drug2Dose2;98 d36 = Drug1Dose3-Drug2Dose3;99 d45 = Drug2Dose1-Drug2Dose2; d46 = Drug2Dose1-Drug2Dose3;100 d56 = Drug2Dose2-Drug2Dose3;101 /* Marginal means and interactions */102 Drug1 = mean(of Drug1Dose1--Drug1Dose3);103 Drug2 = mean(of Drug2Dose1--Drug2Dose3);104 Dose1 = (Drug1Dose1+Drug2Dose1)/2;105 Dose2 = (Drug1Dose2+Drug2Dose2)/2;106 Dose3 = (Drug1Dose3+Drug2Dose3)/2;107 Drugdiff = drug1-drug2;108 doseD12 = dose1-dose2; doseD13 = dose1-dose3;109 doseD23 = dose2-dose3;110 DrugEffect1 = Drug1Dose1-Drug2Dose1;111 DrugEffect2 = Drug1Dose2-Drug2Dose2;112 DrugEffect3 = Drug1Dose3-Drug2Dose3;113 label DrugEffect1 = 'Drug effect for dose 1'114 DrugEffect2 = 'Drug effect for dose 2'115 DrugEffect3 = 'Drug effect for dose 3';116 int1 = DrugEffect1-DrugEffect2;117 int2 = DrugEffect1-DrugEffect3;118 int3 = DrugEffect2-DrugEffect3;119NOTE: There were 10 observations read from the data set WORK.OUCH0.NOTE: The data set WORK.OUCH1 has 10 observations and 37 variables.NOTE: DATA statement used (Total process time):real time 0.01 secondscpu time 0.00 seconds120 proc means data=ouch1 n mean stddev maxdec=3;121 var Drug1Dose1 -- Drug2Dose3122 Drug1 Drug2123 Dose1-Dose3124 DrugEffect1-DrugEffect3;125 run;NOTE: There were 10 observations read from the data set WORK.OUCH1.NOTE: PROCEDURE MEANS used (Total process time):real time 0.10 secondscpu time 0.10 seconds126127 /* Test for overall differences, main effects and interaction.128 Just look at the multivariate output. */129 ods select MultStat (persist);130131 proc reg data=ouch1;132 title2 'Overall test';133 model d12-d16 = ;134 Overall: mtest intercept = 0;135 run;136NOTE: PROCEDURE REG used (Total process time):real time 0.14 secondscpu time 0.12 seconds137 proc reg data=ouch1;138 title2 'Main Effect of Drug';139 model drugdiff = ;140 Drug: mtest intercept = 0;141 /* Could have used test or just looked at the t statistic. */142 run;143NOTE: PROCEDURE REG used (Total process time):real time 0.09 secondscpu time 0.07 seconds144 proc reg;145 title2 'Main Effect of Dose Level';146 model dosed12 dosed13 = ;147 Dose: mtest intercept = 0;148 run;149NOTE: PROCEDURE REG used (Total process time):real time 0.08 secondscpu time 0.07 seconds150 proc reg data=ouch1;151 title2 'Drug by Dose Interaction';152 model int1 int2 = ;153 Drug_by_Dose: mtest intercept = 0;154 run;155156 /* Follow up, including tests of pairwise difference157 even though the overall test was not significant. */158159 ods select all; /* Turning off the selection */160NOTE: PROCEDURE REG used (Total process time):real time 0.08 secondscpu time 0.07 seconds161 proc means data=ouch1 n mean t probt;162 title2 'Follow up with matched t-tests';163 var d12 -- d56164 dosed12--dosed23165 int1-int3 ;166167 /* Specify transformations of response variables within proc reg168169 Dose 1 Dose 2 Dose 3170 ------ ----- ------171 Drug 1 Drug1Dose1 Drug1Dose2 Drug1Dose3172 Drug 2 Drug2Dose1 Drug2Dose2 Drug2Dose3 */173174175 /* Strangely, after the first time I use ods select in a job, it only176 seems to work when I precede it with quit. ods is a little flaky177 with SAS University Edition; maybe that's the reason. */178179 quit;NOTE: There were 10 observations read from the data set WORK.OUCH1.NOTE: PROCEDURE MEANS used (Total process time):real time 0.14 secondscpu time 0.13 seconds179 ! ods select MultStat;180 proc reg data=ouch0 plots=none;181 title2 'Specify new response variables within proc reg';182 model Drug1Dose1 -- Drug2Dose3 = ;183 Overall: mtest intercept = 0,184 Drug1Dose1-Drug1Dose2, Drug1Dose1-Drug1Dose3,185 Drug1Dose1-Drug2Dose1, Drug1Dose1-Drug2Dose2,186 Drug1Dose1-Drug2Dose3;187 Drug: mtest intercept = 0,188 Drug1Dose1+Drug1Dose2+Drug1Dose3189 - Drug2Dose1-Drug2Dose2-Drug2Dose3;190 Dose: mtest intercept = 0,191 Drug1Dose1+Drug2Dose1 - Drug1Dose2-Drug2Dose2,192 Drug1Dose2+Drug2Dose2 - Drug1Dose3-Drug2Dose3;193 Interaction: mtest intercept = 0,194 Drug1Dose1-Drug2Dose1 - Drug1Dose2+Drug2Dose2,195 Drug1Dose1-Drug2Dose1 - Drug1Dose3+Drug2Dose3;196 run;197198 quit;NOTE: PROCEDURE REG used (Total process time):real time 0.17 secondscpu time 0.16 seconds198 ! ods select MultStat GLM.Repeated.WithinSubject.ModelANOVA;199 proc glm data=ouch0;200 title2 'Two-factor within cases the easy way';201 model Drug1Dose1--Drug2Dose3 = ;202 repeated Drug 2, Dosage 3 / short summary;203 /* Factor on the right changes fastest (like numbers) */204 run;205206 quit;NOTE: PROCEDURE GLM used (Total process time):real time 0.21 secondscpu time 0.19 seconds206 ! ods select MultStat GLM.Repeated.WithinSubject.ModelANOVA;207 proc glm data=ouch0;208 title2 'Overall test the easy way';209 model Drug1Dose1--Drug2Dose3 = ;210 repeated treatment / short summary;211 run;212213214215216217218219220 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;233