Home > Output

#
Chapter 3: Writing a research protocol using SAS

###
Figure 3.1 *Output for sample size for a prevalence from SAS*

###
Figure 3.1 Code

Click here to show code as text
/* Make a dataset to specify the prevalence p from 0 to 1, the half width of the
confidence interval, the alpha error level and then do the caculation.*/
data estimateSampleSize;
p = .07; /* Provide an expected frequency ... */
halfWidth = .014; /* and a half width CL (accuracy) ... */
alpha = .05; /* and the alpha level. */
tail = 1-alpha/2; /* This is a two tailed test because of the /2. */
/* The ceil function rounds up. The quantile function returns the percentage
of the tail of a distribution. The two characters ** tell SAS to
exponentiate. */
sampleSize = ceil(quantile('NORMAL',tail)**2 / halfWidth**2 * (p)*(1-p));
run;
/* Print all the variables but not the record number from the estiamtedSampleSize dataset.*/
proc print data = estimateSampleSize noobs;
run;

###
Figure 3.2 *Output from sample size for two proportions from SAS *

###
Figure 3.2 Code

Click here to show code as text
proc power;
twosamplefreq
/* Use Fisher's exact test instead of the default Pearsons's chi-square. */
test = fisher
/* Use this pair of percentages for the power calculation. */
groupproportions = (.67 .56)
npergroup = . /* . is used for the value to estimate. */
power = .9; /* Require 90% power. */
run;

###
Figure 3.3 Output from SAS for sample size of the difference between two means

###
Figure 3.3 Code

Click here to show code as text
proc power;
twosamplemeans
test = diff /* Do a power calulation for a paired t-test (default). */
groupmeans = 3600 | 3420 /* Use one number from each side of the | . */
/* | is useful for making sets of many pairs. */
/* Here we are testing for a difference between
two groups where one has a mean of 3600 and
the other 3420. */
stddev = 500 /* Use your estimated overall/pooled standard
deviation. */
npergroup = . /* . is used for the value to estimate. Here
we want to know how many subjects are needed. */
power = 0.9; /* Require 90% power. */
; /* Notice that the ; goes after all the options. */
run;