1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 /********************* scab1.sas ***************************/
57 title 'Scab Disease Data';
58
59 data potato;
60 infile '/folders/myfolders/ScabDisease.data.txt';
61 length condition $ 10.; /* Default length of character values is 8. */
62 input condition $ infection;
63 label infection = 'Ave percent surface covered';
NOTE: The infile '/folders/myfolders/ScabDisease.data.txt' is:
Filename=/folders/myfolders/ScabDisease.data.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=08Jan2016:21:27:35,
File Size (bytes)=576
NOTE: 32 records were read from the infile '/folders/myfolders/ScabDisease.data.txt'.
The minimum record length was 16.
The maximum record length was 16.
NOTE: The data set WORK.POTATO has 32 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
64 proc freq;
65 tables condition;
66
NOTE: There were 32 observations read from the data set WORK.POTATO.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
67 proc means;
68 class condition;
69 var infection;
70
NOTE: There were 32 observations read from the data set WORK.POTATO.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds
71 proc glm;
72 class condition;
73 model infection = condition / clparm;
74 /* clparm gives CIs for contrasts down in the estimate statements. */
75 /* Pairwise multiple comparisons */
76 lsmeans condition / pdiff tdiff adjust = tukey;
77 lsmeans condition / pdiff tdiff adjust = bon;
78 lsmeans condition / pdiff tdiff adjust = scheffe;
79 /* Test some custom contrasts. Beware of alphabetical order:
80 Control Fall1200 Fall300 Fall600 Spring1200 Spring300 Spring600*/
81 contrast 'Overall test for comparison' condition 1 -1 0 0 0 0 0,
82 condition 1 0 -1 0 0 0 0,
83 condition 1 0 0 -1 0 0 0,
84 condition 1 0 0 0 -1 0 0,
85 condition 1 0 0 0 0 -1 0,
86 condition 1 0 0 0 0 0 -1;
87
88 contrast 'Av. of Fall vs. Control' condition 3 -1 -1 -1 0 0 0;
89 contrast 'Av. of Spring vs. Control' condition 3 0 0 0 -1 -1 -1;
90 contrast 'Fall vs. Spring' condition 0 1 1 1 -1 -1 -1;
91
92 contrast 'Spring Amount' condition 0 0 0 0 1 -1 0,
93 condition 0 0 0 0 0 1 -1;
94
95 contrast 'Fall Amount' condition 0 1 -1 0 0 0 0,
96 condition 0 0 1 -1 0 0 0;
97
98 contrast 'Spr vs. Fall for 300 lbs.' condition 0 0 1 0 0 -1 0;
99 contrast 'Spr vs. Fall for 600 lbs.' condition 0 0 0 1 0 0 -1;
100 contrast 'Spr vs. Fall, 1200 lbs' condition 0 1 0 0 -1 0 0;
101
102 /* Estimate and CI for Control vs. Fall 1200 (F = t^2) */
103 estimate 'Control vs. Fall 1200' condition 1 -1 0 0 0 0 0;
104 estimate 'Control vs. Mean of Fall'
105 condition 3 -1 -1 -1 0 0 0 / divisor = 3;
106
107 /* Scheffe critical value for a test of s contrasts is critval * (p-1)/s.
108 For p=7 means and a single contrast, it's critval * (7-1)/1 */
NOTE: PROCEDURE GLM used (Total process time):
real time 2.14 seconds
cpu time 0.83 seconds
109 proc iml;
NOTE: IML Ready
110 title2 'Critical value for all possible 1-df Scheffe F-tests';
111 numdf = 6;
111 ! /* p-1 = Numerator degrees of freedom for initial test */
112 dendf = 25;
112 ! /* n-p = Denominator degrees of freedom for initial test */
113 alpha = 0.05;
114 critval = finv(1-alpha,numdf,dendf);
114 ! print critval;
115 ScheffeCritval = critval*numdf;
115 ! print ScheffeCritval;
116
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds
117 proc iml;
NOTE: IML Ready
118 title2 'Table of Scheffe critical values for COLLECTIONS of contrasts';
119 numdf = 6;
119 ! /* Numerator degrees of freedom for initial test */
120 dendf = 25;
120 ! /* Denominator degrees of freedom for initial test */
121 alpha = 0.05;
122 critval = finv(1-alpha,numdf,dendf);
123 zero = {0 0};
123 ! S_table = repeat(zero,numdf,1);
123 ! /* Make empty matrix */
124 /* Label the columns */
125 namz = {"Number of Contrasts in followup F-test"
126 " Scheffe Critical Value"};
127 mattrib S_table colname=namz;
128 do i = 1 to numdf;
129 s_table(|i,1|) = i;
130 s_table(|i,2|) = numdf/i * critval;
131 end;
132 reset noname;
132 ! /* Makes output look nicer in this case */
133 print "Initial test has" numdf " and " dendf "degrees of freedom."
134 "Using significance level alpha = " alpha;
135 print s_table;
136
137 /* Example of subsetting vs. contrasts */
138
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
139 proc glm;
140 title2 'Test differences among treatments excluding control';
141 title3 'Using contrasts of all means (traditional)';
142 class condition;
143 model infection = condition;
144 contrast 'Differences excluding control' condition 0 1 -1 0 0 0 0,
145 condition 0 0 1 -1 0 0 0,
146 condition 0 0 0 1 -1 0 0,
147 condition 0 0 0 0 1 -1 0,
148 condition 0 0 0 0 0 1 -1;
NOTE: PROCEDURE GLM used (Total process time):
real time 0.37 seconds
cpu time 0.16 seconds
149 proc glm;
150 title2 'Test differences among treatments excluding control';
151 title3 'Subset the data by excluding control';
152 where condition ne 'Control'; /* Case sensitive */
153 class condition;
154 model infection = condition;
155
156
157 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
169