I need to find the difference of proportions between two treatment groups and obtain their 95% CI via Clopper-Pearson methodology.
Is there a way to use a SAS procedure, such as PROC FREQ, to obtain the 95% CI or do I need to manually calculate?
The following code is what I've tried to use to obtain CI, but none are being outputted.
data have;
label trt= 'Treatment'
param= 'Parameter'
response= 'Response 1=success 2=fail'
x= 'Counts'
n= 'Total'
;
input trt param response x n @@;
cards;
1 1 1 9 13
1 2 1 13 13
1 3 1 6 13
1 1 2 4 13
1 2 2 0 13
1 3 2 7 13
2 1 1 17 18
2 2 1 12 18
2 3 1 14 18
2 1 2 1 18
2 2 2 6 18
2 3 2 4 18
;
proc sort; by param;
proc freq noprint;
by param;
tables trt*response / riskdiff binomial(CL= clopperpearson) out= dsnout1;
weight x;
output binomial n out= dsnout2;
run;
What kind of proportions are you refering to ?
If you mean x/n , then check this:
http://support.sas.com/kb/24/188.html
If you mean Response=1 's ratio(the number of Response=1/ the number of each treat group), check PROC FREQ's relrisk:
proc sort; by param;
proc freq ;
by param;
tables trt*response / riskdiff(column=1 CL=exact) ;
weight x;
output out= dsnout2 riskdiff;
run;
When you use NOPRINT then you told the procedure not print the output for anything. The OUTPUT statement would need to include options related to relative risks if Rel1, Rel2, Riskdiff, Riskdiff1, Riskdiff2, etc, Look at the online help under output, there's about a dozen related.
Or don't use NOprint and do use the ODS output to capture the entire Riskdiff output:
ods output RiskDiffCol1= RisksColumn1 RiskDiffCol2= riskscolumn2 ; proc freq data=have; by param; tables trt*response / riskdiff binomial(CL= clopperpearson) out= dsnout1; weight x; output binomial n out= dsnout2; run;
What kind of proportions are you refering to ?
If you mean x/n , then check this:
http://support.sas.com/kb/24/188.html
If you mean Response=1 's ratio(the number of Response=1/ the number of each treat group), check PROC FREQ's relrisk:
proc sort; by param;
proc freq ;
by param;
tables trt*response / riskdiff(column=1 CL=exact) ;
weight x;
output out= dsnout2 riskdiff;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.