# Thread: sample size calcs - why do these produce different results

1. ## sample size calcs - why do these produce different results

What are the interpretations for each of these?

data a;
input z p q e;
cards;
1.96 0.95 0.05 0.05
;
data b;
set a;
n=(z*z*p*q)/(e*e);
run;
proc print; run;

****************************;

proc power;
onesamplefreq test=z method=normal
sides = 2
alpha = 0.05
nullproportion = 0.90
proportion = 0.95
ntotal = .
power = 0.9;
run;

2. ## Re: sample size calcs - why do these produce different results

I think it would help to better describe what you are trying to do. Are you just trying to recreate the one-sample z-test sample size formula?

If so, where is your power value in the first equation? Can you reference or send a link to the formula you are trying to use?

3. ## Re: sample size calcs - why do these produce different results

I believe this is what you are trying to do:

Code:
``````procpower;
onesamplefreqtest=z method=normal
sides = 2
alpha = 0.05
nullproportion = 0.90
proportion = 0.95
ntotal = .
power = 0.9;
run;

data sample_size_calc;
input z_alpha z_power pop_p sample_p;
sample_size=(((z_alpha*(sqrt(pop_p*(1-pop_p)))) + (z_power*(sqrt(sample_p *(1- sample_p))))) / (pop_p - sample_p) )**2;
datalines;
1.96 1.28 0.90 0.95
;
run;

proc print data=sample_size_calc noobs;
run;
``````
301 versus 300.654

 Tweet