BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Akter
Obsidian | Level 7

I want this output: 

Sample Size

Desired
CI Half Width (%)

Success
Count

Success Rate (%)

Lower Limit of
95% Exact CI

Upper Limit of
95% Exact CI

Actual
CI Half Width (%)

120

  1.00

120

100.00

 96.97

100.00

  1.51

120

  2.50

119

 99.17

 95.44

 99.98

  2.27

120

  3.50

117

 97.50

 92.87

 99.48

  3.31

 

To validate the above table, I tried the below program: 

%let N=120;
data CIop;
do i=117 to &N;
retain N x p L U alpha;
p=i/&N;
alpha=0.05;
if p=0 then L=0;
if p=1 then U=1;
if p ne 0 then L=(1-betainv(1-alpha/2, &N-i+1, i));
if p ne 1 then U=betainv (1-alpha/2, i+1, &N-i);
N=&N;
x=i;
output;
end;
run;
proc print data=CIop;
var N x p L U;
run;

*

I got everything in the above table except the 'Desired CI Half Width' and 'Actual CI Half Width'.

 

How can i get the above complete table with Desired and Expected CI Half Width. 

 

Thank you so much! 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The 'Actual CI Half Width' is (U - L)/2.

 

In case anyone else wants to understand the program, the OP is calculating the exact Clopper-Pearson interval for the binomial proportion. The Clopper-Pearson estimate is used because the proportion of successes (p) is close to 1, which violates the usual scenario in which the more familiar Wald interval is applicable.

 

I'm still not sure what the 'Desired CI Half-Width' column is, but I think it is a "given" column that is provided for us. It looks like the task is similar to a power or sample size computation. The second column is the "target" and the other columns show the CI for the proportion that comes closest to matching this target value. 

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Please explain further. How can it be that the table you want has 7 columns but your PROC PRINT only mentions 5 variables?

--
Paige Miller
Akter
Obsidian | Level 7

Thank you, Paige Miller.

I don't know what should be the program i need to write for these additional two variables, Desired and Actual CI Half Width. That's why i did not put these two variable in the proc print.  At that moment, pls forget the proc print part. Compare my program and the expected output table what additional program i need to write to get the output table or how differently i can write my program. 

 

Respectfully,

 

PaigeMiller
Diamond | Level 26

How do you calculate these two values? What is the formula? (I realize you don't know how to program it in SAS, just tell us the formula for these).

--
Paige Miller
Rick_SAS
SAS Super FREQ

The 'Actual CI Half Width' is (U - L)/2.

 

In case anyone else wants to understand the program, the OP is calculating the exact Clopper-Pearson interval for the binomial proportion. The Clopper-Pearson estimate is used because the proportion of successes (p) is close to 1, which violates the usual scenario in which the more familiar Wald interval is applicable.

 

I'm still not sure what the 'Desired CI Half-Width' column is, but I think it is a "given" column that is provided for us. It looks like the task is similar to a power or sample size computation. The second column is the "target" and the other columns show the CI for the proportion that comes closest to matching this target value. 

Akter
Obsidian | Level 7
Thank you 😊. Great help!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1095 views
  • 0 likes
  • 3 in conversation