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;

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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