<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Calculate exact Clopper-Pearson binomial 95% CI in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778181#M247702</link>
    <description>&lt;P&gt;I want to find the exact binomial 95% CI for each symptom (SYMP) within each cohort and dose. The end result will be something along the lines of&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 480pt;" border="0" width="640" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD rowspan="2" width="78.267px" height="68px" class="xl68" style="border-bottom: .5pt solid black; height: 30.0pt; width: 48pt;"&gt;&lt;STRONG&gt;Symptom&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.875px" height="53px" class="xl69" style="border-right: .5pt solid black; border-left: none; width: 144pt;"&gt;&lt;STRONG&gt;Cohort A&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.875px" height="53px" class="xl69" style="border-right: .5pt solid black; border-left: none; width: 144pt;"&gt;&lt;STRONG&gt;Cohort B&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.989px" height="53px" class="xl70" style="border-right: .5pt solid black; width: 144pt;"&gt;&lt;STRONG&gt;Cohort C&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="50.6108px" height="15px" class="xl65" style="height: 15.0pt; border-left: none;"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.6534px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl65" style="border-left: none;"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.6534px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.767px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;redness&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;tender&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;pain&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl74" style="height: 14.4pt;"&gt;…&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl65" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl65" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have gotten this far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Cohort A (N=75), Cohort B(N=84), Cohort C(N=61)*/
data have;
	input cohort $ dose $ symp $ cnt pct;
	cards;
		A	01	redness	10	13.3
		A	01	tender	3	4
		A	01	pain	8	10.7
		A	02	redness	9	12
		A	02	tender	6	8
		A	02	pain	4	5.3
		A	03	redness	6	8
		A	03	pain	12	16
		B	01	tender	21	25
		B	01	pain	13	15.5
		B	02	redness	16	19
		B	02	tender	14	16.7
		B	02	pain	8	9.5
		B	03	redness 7	8.3
		B	03	tender	12	14.3
		C	01	redness	17	27.9
		C	02	redness	12	19.7
		C	02	tender	6	9.8
		C	03	redness	8	13.1
		C	03	tender	9	14.8
		C	03	pain	1	1.7
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I attempted to use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have (where= (cohort = "A" dose = "01"));
 weight cnt;
 tables symp / nocum binomial;
 exact binomial;
 ods output Binomial = have_ci;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My initial idea was to make a macro to run through each cohort and dose combination. However, this method does not give me a 95% CI for all different symptoms (only gives first listed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an efficient way to get to my goal? Or will I need to run through each individual combination of cohort, dose, and symptom within PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data I used to get to "have" looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*participants without a symptom (occurence = 0 or missing) were removed*/
data orig;
	input id $ cohort $ dose $ symp $ day occurence;
	cards;
		MD001	A	01	redness	1	1
		MD001	A	02	redness	2	1
		MD002	A	01	redness	1	1
		MD002	A	01	tender	1	1
		MD002	A	02	redness	2	1
		MD002	A	03	redness	3	1
		MD003	B	01	tender	1	1
		MD003	B	02	redness	2	1
		MD003	B	02	tender	2	1
		MD003	B	03	redness	3	1
		MD004	A	01	tender	1	1
		MD004	A	02	redness	2	1
		MD005	C	01	tender	1	1
		MD005	C	01	pain	1	1
		MD005	C	03	redness	3	1
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;count(distinct ID) was used to obtain counts (CNT) seen in the "have" dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; There are more symptoms and cohorts than listed. There are technically less participants than I used in my example, but I didn't feel like re-writing the counts and percentages. Clopper-Pearson 95% CI is specified in the analysis plan.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Nov 2021 13:24:51 GMT</pubDate>
    <dc:creator>mariko5797</dc:creator>
    <dc:date>2021-11-03T13:24:51Z</dc:date>
    <item>
      <title>Calculate exact Clopper-Pearson binomial 95% CI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778181#M247702</link>
      <description>&lt;P&gt;I want to find the exact binomial 95% CI for each symptom (SYMP) within each cohort and dose. The end result will be something along the lines of&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 480pt;" border="0" width="640" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD rowspan="2" width="78.267px" height="68px" class="xl68" style="border-bottom: .5pt solid black; height: 30.0pt; width: 48pt;"&gt;&lt;STRONG&gt;Symptom&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.875px" height="53px" class="xl69" style="border-right: .5pt solid black; border-left: none; width: 144pt;"&gt;&lt;STRONG&gt;Cohort A&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.875px" height="53px" class="xl69" style="border-right: .5pt solid black; border-left: none; width: 144pt;"&gt;&lt;STRONG&gt;Cohort B&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD colspan="3" width="186.989px" height="53px" class="xl70" style="border-right: .5pt solid black; width: 144pt;"&gt;&lt;STRONG&gt;Cohort C&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="50.6108px" height="15px" class="xl65" style="height: 15.0pt; border-left: none;"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.6534px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl65" style="border-left: none;"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.6534px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;n&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="50.6108px" height="15px" class="xl63"&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="85.767px" height="15px" class="xl66"&gt;&lt;STRONG&gt;95% CI&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;redness&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;tender&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl73" style="height: 14.4pt;"&gt;pain&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl67" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl64"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="78.267px" height="14px" class="xl74" style="height: 14.4pt;"&gt;…&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl65" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl65" style="border-left: none;"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.6534px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="50.6108px" height="14px" class="xl63"&gt;x&lt;/TD&gt;
&lt;TD width="85.767px" height="14px" class="xl66"&gt;(x.x, x.x)&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have gotten this far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Cohort A (N=75), Cohort B(N=84), Cohort C(N=61)*/
data have;
	input cohort $ dose $ symp $ cnt pct;
	cards;
		A	01	redness	10	13.3
		A	01	tender	3	4
		A	01	pain	8	10.7
		A	02	redness	9	12
		A	02	tender	6	8
		A	02	pain	4	5.3
		A	03	redness	6	8
		A	03	pain	12	16
		B	01	tender	21	25
		B	01	pain	13	15.5
		B	02	redness	16	19
		B	02	tender	14	16.7
		B	02	pain	8	9.5
		B	03	redness 7	8.3
		B	03	tender	12	14.3
		C	01	redness	17	27.9
		C	02	redness	12	19.7
		C	02	tender	6	9.8
		C	03	redness	8	13.1
		C	03	tender	9	14.8
		C	03	pain	1	1.7
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I attempted to use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have (where= (cohort = "A" dose = "01"));
 weight cnt;
 tables symp / nocum binomial;
 exact binomial;
 ods output Binomial = have_ci;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My initial idea was to make a macro to run through each cohort and dose combination. However, this method does not give me a 95% CI for all different symptoms (only gives first listed).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an efficient way to get to my goal? Or will I need to run through each individual combination of cohort, dose, and symptom within PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data I used to get to "have" looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*participants without a symptom (occurence = 0 or missing) were removed*/
data orig;
	input id $ cohort $ dose $ symp $ day occurence;
	cards;
		MD001	A	01	redness	1	1
		MD001	A	02	redness	2	1
		MD002	A	01	redness	1	1
		MD002	A	01	tender	1	1
		MD002	A	02	redness	2	1
		MD002	A	03	redness	3	1
		MD003	B	01	tender	1	1
		MD003	B	02	redness	2	1
		MD003	B	02	tender	2	1
		MD003	B	03	redness	3	1
		MD004	A	01	tender	1	1
		MD004	A	02	redness	2	1
		MD005	C	01	tender	1	1
		MD005	C	01	pain	1	1
		MD005	C	03	redness	3	1
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;count(distinct ID) was used to obtain counts (CNT) seen in the "have" dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; There are more symptoms and cohorts than listed. There are technically less participants than I used in my example, but I didn't feel like re-writing the counts and percentages. Clopper-Pearson 95% CI is specified in the analysis plan.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 13:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778181#M247702</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-11-03T13:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate exact Clopper-Pearson binomial 95% CI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778219#M247707</link>
      <description>&lt;P&gt;Do I understand correctly that you need something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input cohort $ dose $ symp $ cnt pct;
	cards;
		A	01	redness	10	13.3
		A	01	tender	3	4
		A	01	pain	8	10.7
		A	02	redness	9	12
		A	02	tender	6	8
		A	02	pain	4	5.3
		A	03	redness	6	8
		A	03	pain	12	16
		B	01	tender	21	25
		B	01	pain	13	15.5
		B	02	redness	16	19
		B	02	tender	14	16.7
		B	02	pain	8	9.5
		B	03	redness 7	8.3
		B	03	tender	12	14.3
		C	01	redness	17	27.9
		C	02	redness	12	19.7
		C	02	tender	6	9.8
		C	03	redness	8	13.1
		C	03	tender	9	14.8
		C	03	pain	1	1.7
	;
run;

proc sort data = have out=have;
  by cohort dose symp;
run;

%macro loop(list, ds=have);

%local n;
%let n = %sysfunc(countw(&amp;amp;list.));

%do i = 1 % to &amp;amp;N.;
  /* to avoid "BINOMIAL LEVEL='xxxxx' is not found for variable YYYY." errors */
  proc sql noprint;
    create table INPUTTABLE as
    select a.* 
    from
      &amp;amp;ds. as a
      inner join
      ( select distinct cohort, dose 
        from &amp;amp;ds. 
        where symp = "%scan(&amp;amp;list.,&amp;amp;i.)"
      ) as b 
      on a.cohort = b.cohort and a.dose = b.dose
    order by
      cohort, dose
    ;
  quit;
  
  ods select none;
  proc freq data = INPUTTABLE;
   by cohort dose;
   weight cnt;
   tables symp / nocum binomial(OUTLEVEL LEVEL="%scan(&amp;amp;list.,&amp;amp;i.)") noprint;
   exact binomial;
   ods output Binomial = have_ci_&amp;amp;i.(where=(Name1 in: ("XU", "XL")));
  run;
  ods select all;


  proc print data=have_ci_&amp;amp;i.;
  run;
%end;

%mend;

proc sql;
  select distinct symp 
  into :list separated by " " 
  from have(where=(cohort="A" and dose="01"))
  ;
quit; 

options mprint;
%loop(&amp;amp;list.)

data all_have_ci;
  set have_ci_:;
  
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;B.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 14:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778219#M247707</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-11-03T14:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate exact Clopper-Pearson binomial 95% CI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778233#M247711</link>
      <description>&lt;P&gt;This is amazing! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 15:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-exact-Clopper-Pearson-binomial-95-CI/m-p/778233#M247711</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-11-03T15:14:33Z</dc:date>
    </item>
  </channel>
</rss>

