@msecic: I think you should first decide which confidence interval you want to compute. Your code uses the default, which is the exact binomial test, corresponding to the exact Clopper-Pearson confidence interval.
If you want this, PROC POWER doesn't give you the option to calculate NTOTAL for a given power. I guess the reason is that the results could be easily misinterpreted: Due to discreteness effects, the power does not increase monotonically with sample size (the corresponding graph has a sawtooth shape).
But PROC POWER lets you calculate the power for a range of sample sizes:
ntotal= 90 to 120
power= .;
In the results you see that the power of 80% is achieved with n=99 and n=100, but then drops below 80% as n further increases up to n=104 (power 76.1%). Only after another rise and fall it finally crosses the 80% mark for n>=112.
If you know the formula for the lower confidence limit of your choice, it's not difficult to compute the power even without PROC POWER. Here's the code using the lower limit of the one-sided Clopper-Pearson CI (replicating the results of PROC POWER):
%let alpha=0.05;
%let p0=0.81;
%let p =0.90;
data want;
do n=90 to 120;
do k=0 to n;
if k>0 then pL=k/(k+(n-k+1)*quantile('F',1-&alpha,2*(n-k+1),2*k)); else pL=0;
if pL>=&p0 then leave;
end;
power=1-cdf('binom',k-1,&p,n);
output;
end;
keep n power;
run;
proc print data=want noobs;
format power 5.3;
run;
... View more