The following two papers by Professor Robert Newcombe, in my limit observation, are the most frequently cited papers in the industry for CI calculation:
- Two-sided confidence intervals for the single proportion: comparison of seven methods.
Newcombe RG, Stat Med , Volume 17 , 8 (April 1998) pp.857-872
- Interval estimation for the difference between independent proportions: comparison of eleven methods.
Newcombe RG, Stat Med , Volume 17 , 8 (April 1998) pp.873-890
This post serves as an implementation using SAS accompany with the first paper on confidence intervals for single proportion(method 1-7). Additional 4 methods also provided:
1. Simple asymptotic, Without CC
2. Simple asymptotic, With CC
3. Score method, Without CC
4. Score method, With CC
5. Binomial-based, ‘Exact’
6. Binomial-based, Mid-p
9. Agresti-Coull,z^2⁄2 successes
10. Agresti-Coull,2 successes and 2 fail
The codes are available at
It is a purely SAS/Base(data step and SQL) approach. I prefer data steps because it can be seamlessly incorporate into production work which looks like:
/r is the observed number of events/responders in n observations;/
z = probit (1-&alpha/2);
sd=sqrt(&np(1-p)); *Standard Deviation ;
se=sd/&n; *standard error;
me=z*se; *margin of error;
p_CI_low = p-me;
p_CI_up = p+me;
input r n;
keep r n p p_CI;
proc print data=test;run;
But when simulation required (in methods 6-7), some SQL clauses pop up. Admit that It makes the codes less elegant. In this situation, matrix operation language such as SAS/IML or R will do a better job.
Note that in SAS 9.2, PROC FREQ can produce the following five intervals(method 1, 3, 9 ,8, 5):
Wald (also with method 2)
For the five intervals in SAS 9.2, a good reference is Confidence Intervals for the Binomial Proportion with Zero Frequency by Xiaomin He and Shwu-Jen Wu:
Also, an equivalent R version of the eleven methods by Abteilung Kriminologie is also available at
Such R repository is also a good resource for SAS users. I almost “translate” R implementations directly to SAS for this post.