1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 /* sampvar.sas */
72 title 'Sample variation method for selecting sample size';
73
74 /* Suppose we are planning a 2x3x4 analysis of covariance,
75 with two covariates, and factors named A, B and C. We
76 are setting it up as a regression model, with one dummy
77 variable for A, 2 dummy variables for B, and 3 for C.
78 Interactions are represented by product terms, and there
79 are 2 products for the AxB interaction, 3 for AxC, 6 for
80 BxC, and 1*2*3 = 6 for AxBxC. The regression coefficients
81 for these plus two for the covariates and one for the
82 intercept give us p = 26. The null hypothesis is that of no
83 BxC interaction, so s = 6. The "other effects in the
84 model" for which we are "controlling" are represented
85 by 2 covariates and 17 dummy variables and products of
86 dummy variables. */
87
88 proc iml;
NOTE: IML Ready
89 title2 'Find n given a';
90 alpha = 0.05;
90 ! /* Significance level. */
91 s = 6;
91 ! /* Numerator df = # Expl vars tested. */
92 p = 26;
92 ! /* There are p beta parameters. */
93 a = .10 ;
93 ! /* Proportion of remaining variation after */
94 /* controlling for all other variables. */
95 /* Initializing ... */
95 ! pval = 1;
95 ! n = p;
96 do until (pval <= alpha);
97 n = n+1 ;
98 F = (n-p)/s * a/(1-a);
99 df2 = n-p;
100 pval = 1-probf(F,s,df2);
101 end;
102 print "Required sample size is" n;
103 quit;
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
real time 0.02 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 2276.84k
OS Memory 29604.00k
Timestamp 04/01/2020 08:08:58 AM
Step Count 77 Switch Count 1
Page Faults 0
Page Reclaims 974
Page Swaps 0
Voluntary Context Switches 7
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
104
105 /* In the potato data, there are 3 potatoes per treatment
106 combination in a temperature (2 levels) by Bacteria type
107 (3 levels) by oxygen level (3 levels) design. What pro-
108 portion of remaining variation is required for the
109 main effect of bacteria type to be significant? */
110
111 proc iml;
NOTE: IML Ready
112 title2 'Find a given n';
113 alpha = 0.05;
113 ! /* Significance level. */
114 s = 2;
114 ! /* Numerator df = # Expl vars tested. */
115 p = 18;
115 ! /* There are p beta parameters. */
116 n = 54 ;
116 ! /* Sample size */
117
118 /* Initializing ... */
118 ! a = 0;
118 ! df2 = n-p;
119 do until (pval <= alpha);
120 a = a + .001 ;
121 F = (n-p)/s * a/(1-a);
122 pval = 1-probf(F,s,df2);
123 end;
124 print "Required proportion of remaining variation is" a;
125 quit;
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 587.25k
OS Memory 29860.00k
Timestamp 04/01/2020 08:08:58 AM
Step Count 78 Switch Count 1
Page Faults 0
Page Reclaims 164
Page Swaps 0
Voluntary Context Switches 8
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
126
127
128
129 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
140