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
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!
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;
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.