1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 /********************* scab1.sas ***************************/
74 title 'Scab Disease Data';
75 title2 'Read Data from an Excel Spreadsheet';
76
77 proc import datafile="/home/u1407221/441s24/SAS03/ScabDisease.xlsx"
78 out=scab dbms=xlsx replace;
79 getnames=yes;
80 /* Input data file is ScabDisease.xlsx
81 Ouput data table is called scab.
82 dbms=xlsx The input file is an Excel spreadsheet.
83 Necessary to read an Excel spreadsheet directly under unix/linux
84 Works in PC environment too except for Excel 4.0 spreadsheets
85 If there are multiple sheets, use sheet="sheet1" or something.
86 replace If the data table already exists, replace it. Use this!
87 getnames=yes Use column names as variable names. Beware of embedded,
88 leading and trailing blanks.
89 By default, blanks in a spreadsheet are missing. */
90
NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with
options MSGLEVEL=I.
NOTE: The import data set has 32 observations and 2 variables.
NOTE: WORK.SCAB data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
memory 3328.15k
OS Memory 33020.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 97 Switch Count 4
Page Faults 0
Page Reclaims 816
Page Swaps 0
Voluntary Context Switches 29
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
91 proc print; /* By default, use the most recently created data set. */
92
NOTE: There were 32 observations read from the data set WORK.SCAB.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.03 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 2624.37k
OS Memory 31144.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 98 Switch Count 0
Page Faults 0
Page Reclaims 164
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
93 data potato;
94 set scab;
95 label infection = 'Ave percent surface covered';
96
NOTE: There were 32 observations read from the data set WORK.SCAB.
NOTE: The data set WORK.POTATO has 32 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 937.90k
OS Memory 31660.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 99 Switch Count 2
Page Faults 0
Page Reclaims 198
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
97 proc freq; /* Now the most recently created data set is potato. */
98 tables condition;
99
NOTE: There were 32 observations read from the data set WORK.POTATO.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.02 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 1302.93k
OS Memory 31660.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 100 Switch Count 2
Page Faults 0
Page Reclaims 167
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
100 proc means;
101 class condition;
102 var infection;
103
NOTE: There were 32 observations read from the data set WORK.POTATO.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.02 seconds
user cpu time 0.02 seconds
system cpu time 0.01 seconds
memory 8271.50k
OS Memory 39868.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 101 Switch Count 1
Page Faults 0
Page Reclaims 1968
Page Swaps 0
Voluntary Context Switches 12
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 24
104 proc boxplot;
105 plot infection*condition; /* Deliberately unsorted */
106
NOTE: Since an input data set was not specified, data set POTATO is assumed as a DATA= data set.
NOTE: Processing beginning for PLOT statement number 1.
NOTE: There were 32 observations read from the data set WORK.POTATO.
NOTE: PROCEDURE BOXPLOT used (Total process time):
real time 0.24 seconds
user cpu time 0.11 seconds
system cpu time 0.03 seconds
memory 27813.68k
OS Memory 57996.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 102 Switch Count 0
Page Faults 0
Page Reclaims 7265
Page Swaps 0
Voluntary Context Switches 914
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 1056
107 proc glm plots=none;
108 title3 'All pairwise comparisons';
109 class condition;
110 model infection = condition;
111 /* Pairwise multiple comparisons */
112 lsmeans condition / pdiff tdiff; /* No correction */
113 lsmeans condition / pdiff tdiff adjust = tukey;
114 lsmeans condition / pdiff tdiff adjust = bon;
115 lsmeans condition / pdiff tdiff adjust = scheffe;
116
NOTE: PROCEDURE GLM used (Total process time):
real time 0.26 seconds
user cpu time 0.26 seconds
system cpu time 0.00 seconds
memory 3077.06k
OS Memory 57784.00k
Timestamp 01/01/2024 07:48:45 PM
Step Count 103 Switch Count 3
Page Faults 0
Page Reclaims 604
Page Swaps 0
Voluntary Context Switches 21
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 408
117 proc glm order=data; /* Use order in data file, not alphabetical */
118 title3 'Custom Tests';
119 class condition;
120 model infection = condition / clparm;
121 /* clparm gives CIs for contrasts down in the estimate statements. */
122 /* Test the custom contrasts. */
123 contrast '1: Overall test, for comparison'
124 condition 1 -1 0 0 0 0 0,
125 condition 1 0 -1 0 0 0 0,
126 condition 1 0 0 -1 0 0 0,
127 condition 1 0 0 0 -1 0 0,
128 condition 1 0 0 0 0 -1 0,
129 condition 1 0 0 0 0 0 -1;
130 contrast '2a: Spring300 vs. Control' condition 1 -1 0 0 0 0 0;
131 contrast '2b: Spring600 vs. Control' condition 1 0 -1 0 0 0 0;
132 contrast '2c: Spring1200 vs. Control' condition 1 0 0 -1 0 0 0;
133 contrast '2d: Fall300 vs. Control' condition 1 0 0 0 -1 0 0;
134 contrast '2e: Fall600 vs. Control' condition 1 0 0 0 0 -1 0;
135 contrast '2f: Fall1200 vs. Control' condition 1 0 0 0 0 0 -1;
136 contrast '3: Spring vs. Control' condition 3 -1 -1 -1 0 0 0;
137 contrast '4: Fall vs. Control' condition 3 0 0 0 -1 -1 -1;
138 contrast '5: Spring vs. Fall' condition 0 1 1 1 -1 -1 -1;
139
140 contrast '6: Spring Amount' condition 0 1 -1 0 0 0 0,
141 condition 0 0 1 -1 0 0 0;
142
143 contrast '7: Fall Amount' condition 0 0 0 0 1 -1 0,
144 condition 0 0 0 0 0 1 -1;
145
146 contrast '8a: Spr vs. Fall for 300 lbs.' condition 0 1 0 0 -1 0 0;
147 contrast '8b: Spr vs. Fall for 600 lbs.' condition 0 0 1 0 0 -1 0;
148 contrast '8c: Spr vs. Fall, 1200 lbs' condition 0 0 0 1 0 0 -1;
149
150 /* Estimate and CI for Control vs. Fall 1200 (F = t^2) */
151 estimate 'Control vs. Fall 1200' condition 1 0 0 0 0 0 -1;
152 estimate 'Control vs. Mean of Fall'
153 condition 3 0 0 0 -1 -1 -1 / divisor = 3;
154 estimate 'Spring minus Fall'
155 condition 0 1 1 1 -1 -1 -1 / divisor = 3;
156
157 /* Scheffe critical value for a test of s contrasts is critval * (p-1)/s.
158 For p=7 means and a single contrast, it's critval * (7-1)/1 */
NOTE: PROCEDURE GLM used (Total process time):
real time 0.24 seconds
user cpu time 0.12 seconds
system cpu time 0.01 seconds
memory 4791.62k
OS Memory 59068.00k
Timestamp 01/01/2024 07:48:46 PM
Step Count 104 Switch Count 3
Page Faults 0
Page Reclaims 843
Page Swaps 0
Voluntary Context Switches 707
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 1000
159 proc iml;
NOTE: IML Ready
160 title2 'Critical value for all possible 1-df Scheffe F-tests';
161 numdf = 6;
161 ! /* p-1 = Numerator degrees of freedom for initial test */
162 dendf = 25;
162 ! /* n-p = Denominator degrees of freedom for initial test */
163 alpha = 0.05;
164 critval = finv(1-alpha,numdf,dendf);
164 ! print critval;
165 ScheffeCritval = critval*numdf;
165 ! print ScheffeCritval;
166
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.01 seconds
user cpu time 0.02 seconds
system cpu time 0.00 seconds
memory 487.28k
OS Memory 56740.00k
Timestamp 01/01/2024 07:48:46 PM
Step Count 105 Switch Count 1
Page Faults 0
Page Reclaims 55
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
167 proc iml;
NOTE: IML Ready
168 title2 'Table of Scheffe critical values for COLLECTIONS of contrasts';
169 numdf = 6;
169 ! /* Numerator degrees of freedom for initial test */
170 dendf = 25;
170 ! /* Denominator degrees of freedom for initial test */
171 alpha = 0.05;
172 critval = finv(1-alpha,numdf,dendf);
173 zero = {0 0};
173 ! S_table = repeat(zero,numdf,1);
173 ! /* Make empty matrix */
174 /* Label the columns */
175 namz = {"Number of Contrasts in followup F-test"
176 " Scheffe Critical Value"};
177 mattrib S_table colname=namz;
178 do i = 1 to numdf;
179 s_table(|i,1|) = i;
180 s_table(|i,2|) = numdf/i * critval;
181 end;
182 reset noname;
182 ! /* Makes output look nicer in this case */
183 print "Initial test has" numdf " and " dendf "degrees of freedom."
184 "Using significance level alpha = " alpha;
185 print s_table;
186
187 /* Example of subsetting vs. contrasts */
188
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 573.65k
OS Memory 56740.00k
Timestamp 01/01/2024 07:48:46 PM
Step Count 106 Switch Count 1
Page Faults 0
Page Reclaims 56
Page Swaps 0
Voluntary Context Switches 8
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
189 proc glm;
190 title2 'Test differences among treatments excluding control';
191 title3 'Using contrasts of all means (traditional)';
192 class condition;
193 model infection = condition;
194 contrast 'Differences excluding control' condition 0 1 -1 0 0 0 0,
195 condition 0 0 1 -1 0 0 0,
196 condition 0 0 0 1 -1 0 0,
197 condition 0 0 0 0 1 -1 0,
198 condition 0 0 0 0 0 1 -1;
199
NOTE: PROCEDURE GLM used (Total process time):
real time 0.20 seconds
user cpu time 0.10 seconds
system cpu time 0.01 seconds
memory 4598.34k
OS Memory 59068.00k
Timestamp 01/01/2024 07:48:46 PM
Step Count 107 Switch Count 4
Page Faults 0
Page Reclaims 726
Page Swaps 0
Voluntary Context Switches 722
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 984
200 proc glm plots=none;
201 title2 'Test differences among treatments excluding control';
202 title3 'Subset the data by excluding control';
203 where condition ne 'Control'; /* Case sensitive */
204 class condition;
205 model infection = condition;
206
207 run;
208
209
210 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
222