1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7071 /* sampvar.sas */72 title 'Sample variation method for selecting sample size';7374 /* Suppose we are planning a 2x3x4 analysis of covariance,75 with two covariates, and factors named A, B and C. We76 are setting it up as a regression model, with one dummy77 variable for A, 2 dummy variables for B, and 3 for C.78 Interactions are represented by product terms, and there79 are 2 products for the AxB interaction, 3 for AxC, 6 for80 BxC, and 1*2*3 = 6 for AxBxC. The regression coefficients81 for these plus two for the covariates and one for the82 intercept give us p = 26. The null hypothesis is that of no83 BxC interaction, so s = 6. The "other effects in the84 model" for which we are "controlling" are represented85 by 2 covariates and 17 dummy variables and products of86 dummy variables. */8788 proc iml;NOTE: IML Ready89 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 secondsuser cpu time 0.01 secondssystem cpu time 0.01 secondsmemory 2276.84kOS Memory 29604.00kTimestamp 04/01/2020 08:08:58 AMStep Count 77 Switch Count 1Page Faults 0Page Reclaims 974Page Swaps 0Voluntary Context Switches 7Involuntary Context Switches 0Block Input Operations 0Block Output Operations 8104105 /* In the potato data, there are 3 potatoes per treatment106 combination in a temperature (2 levels) by Bacteria type107 (3 levels) by oxygen level (3 levels) design. What pro-108 portion of remaining variation is required for the109 main effect of bacteria type to be significant? */110111 proc iml;NOTE: IML Ready112 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 */117118 /* 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 secondsuser cpu time 0.01 secondssystem cpu time 0.00 secondsmemory 587.25kOS Memory 29860.00kTimestamp 04/01/2020 08:08:58 AMStep Count 78 Switch Count 1Page Faults 0Page Reclaims 164Page Swaps 0Voluntary Context Switches 8Involuntary Context Switches 0Block Input Operations 0Block Output Operations 0126127128129 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;140