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

Hi, 

 

I'm a beginner with SAS and hoping someone can help simplify what I need to do to get confidence intervals for my categorical data. 

 

I have 3 variables (a, b, c) and counts (33, 18, 132) of how many people belong to each category. 

 

I'm trying to figure out how to get the confidence intervals for each proportion. 

 

I've done some research and tried grasping the concepts presented here: 

https://blogs.sas.com/content/iml/2017/02/15/confidence-intervals-multinomial-proportions.html

https://communities.sas.com/t5/Statistical-Procedures/95-CONFIDENCE-INTERVALS-for-categorical-variab...

 

And I'm getting no where since I don't know how to take the proposed codes and apply them to my data appropriately. 

 

If someone can help me with a simple code/an explanation on what to add after these primary lines: 

 

data a; 

input category count; 

datalines; 

a 33

b 18 

c 133

;

 

I'd really appreciate any help I can get. I also found plenty of help for binomial proportions... which seems alot easier... but doesn't really apply here I don't think. 

 

Thanks so much!

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @bionicles and welcome to the SAS Support Communities!

 

Here's an adaptation of what I posted in a 2018 thread to your input dataset:

data have;
input category $ count; 
datalines; 
a 33
b 18 
c 133
;

/* Compute Goodman (1965) confidence intervals for the multinomial proportions */

%let alpha=0.05;

data want(drop=nt x);
if _n_=1 then do;
  do until(lr);
    set have end=lr nobs=c;
    nt+count;
  end;
  x+cinv(1-&alpha/c,1); /* chi-square quantile, df=1, with Bonferroni adjustment */
end;
set have;
p=count/nt;
lcl=(x+2*count-sqrt(x*(x+4*count*(nt-count)/nt)))/(2*(nt+x));
ucl=(x+2*count+sqrt(x*(x+4*count*(nt-count)/nt)))/(2*(nt+x));
run;

 

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @bionicles and welcome to the SAS Support Communities!

 

Here's an adaptation of what I posted in a 2018 thread to your input dataset:

data have;
input category $ count; 
datalines; 
a 33
b 18 
c 133
;

/* Compute Goodman (1965) confidence intervals for the multinomial proportions */

%let alpha=0.05;

data want(drop=nt x);
if _n_=1 then do;
  do until(lr);
    set have end=lr nobs=c;
    nt+count;
  end;
  x+cinv(1-&alpha/c,1); /* chi-square quantile, df=1, with Bonferroni adjustment */
end;
set have;
p=count/nt;
lcl=(x+2*count-sqrt(x*(x+4*count*(nt-count)/nt)))/(2*(nt+x));
ucl=(x+2*count+sqrt(x*(x+4*count*(nt-count)/nt)))/(2*(nt+x));
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1387 views
  • 0 likes
  • 2 in conversation