1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 /* pain2.sas (2018 version) */
74 title 'Covariance structure repeated measures analysis of the pain data';
75
76 /* Read data from an old .xls spreadsheet */
77 proc import datafile="/folders/myfolders/441s18/Lecture/Pain.xls"
78 out=ouch0 dbms=xls replace;
79 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 seconds
cpu time 0.01 seconds
80 proc print;
81
82 /* Dose 1 Dose 2 Dose 3
83 ------ ----- ------
84 Drug 1 Drug1Dose1 Drug1Dose2 Drug1Dose3
85 Drug 2 Drug2Dose1 Drug2Dose2 Drug2Dose3 */
86
NOTE: There were 10 observations read from the data set WORK.OUCH0.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.07 seconds
cpu time 0.08 seconds
87 data hurt;
88 set ouch0;
89 /* Need each response on a separate line for proc mixed. */
90 array response{6} Drug1Dose1 -- Drug2Dose3;
91 index = 0;
92 do drug = 1 to 2;
93 do dose = 1 to 3;
94 index = index + 1;
95 pain = response{index};
96 output;
97 end;
98 end;
99 keep patient drug dose pain;
100
NOTE: There were 10 observations read from the data set WORK.OUCH0.
NOTE: The data set WORK.HURT has 60 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
101 proc print data = hurt (obs=12); /* Just the first 12 lines */
102
NOTE: There were 12 observations read from the data set WORK.HURT.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.05 seconds
cpu time 0.06 seconds
103 proc mixed data=hurt;
104 title2 'Unknown covariance structure';
105 class drug dose;
106 model pain = drug|dose;
107 repeated / type=un subject=patient;
108 /* Pairwise comparisons of marginal means for Dose */
109 lsmeans dose / pdiff tdiff adjust = bon;
110 run;
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.24 seconds
cpu time 0.23 seconds
111
112 proc mixed data=hurt;
113 title2 'Compound symmetry';
114 class drug dose;
115 model pain = drug|dose;
116 repeated / type=cs subject=patient;
117 lsmeans dose / pdiff tdiff adjust = bon;
118 run;
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.20 seconds
cpu time 0.18 seconds
119
120 /* F-tests from cs do not match up with the proc glm univariate tests
121 in pain1.sas that are produced as a by-product of the multivariate
122 approach. If you know how to read it, output from the code below
123 shows that for this (simple and quite common) example, exact classical
124 F-tests for the main effects do not exist unless the interaction is
125 assumed to be absent. The proc mixed tests match what you get by making
126 this assumption. It seems that the "by-product" univariate repeated
127 measures analysis produced by proc glm is doing something else. I do
128 not know exactly what it is doing, except that in every example I can
129 find where all the classical tests DO exist, proc glm matches them.
130 If we want the compound symmetry assumption, we will use proc mixed. */
131
132 proc glm data=hurt noprint; /* Not showing the output */
133 title2 'Trying classical the old fashioned way';
134 class patient drug dose;
135 model pain = patient drug|dose;
136 random patient / test;
137 run;
138
139
140
141 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
154