<?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 Re: How to calculate confidence interval for crude rate by using age group data by years in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640800#M78291</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/318226"&gt;@nastya&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for sharing the link to openepi.com. This is interesting. Now it's easy to provide SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data
   (n=Number of cases, pt=person-time, ptu=person-time unit) */

data have;
input n pt ptu;
cards;
   5       25     10
4060 76513290 100000
;

/* Compute crude rate with two confidence intervals:
   exact Poisson CI and Byar's approximation */

%let alpha=0.05;

data want;
set have;
rate=n/pt*ptu;
lcl_exact=cinv(&amp;amp;alpha/2,2*n)/2/pt*ptu;
ucl_exact=cinv(1-&amp;amp;alpha/2,2*(n+1))/2/pt*ptu;
lcl_Byar=max(n*(1-1/(9*n)-probit(1-&amp;amp;alpha/2)/3*sqrt(1/n))**3/pt*ptu,0);
ucl_Byar=(n+1)*(1-1/(9*(n+1))+probit(1-&amp;amp;alpha/2)/3*sqrt(1/(n+1)))**3/pt*ptu;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                           lcl_       ucl_
   n          pt       ptu      rate      exact      exact     lcl_Byar    ucl_Byar

   5          25        10    2.00000    0.64939    4.66733     0.64454     4.66727
4060    76513290    100000    5.30627    5.14429    5.47205     5.14429     5.47205&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used your example and the example in the documentation&amp;nbsp;&lt;A href="https://www.openepi.com/PDFDocs/PersonTime1Doc.pdf" target="_blank" rel="noopener"&gt;https://www.openepi.com/PDFDocs/PersonTime1Doc.pdf&lt;/A&gt;, p. 2, in dataset HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the exact CI the openepi online calculator uses an iterative algorithm based on the Poisson probability function, whereas my SAS code uses the well-known relationship between the Poisson and chi-square distributions. Note that the formula for the lower confidence limit in the openepi documentation (see link above), p. 3, section "Fisher's exact test," is incorrect: The upper summation limit should read &lt;STRONG&gt;a-1&lt;/STRONG&gt;, not &lt;STRONG&gt;a&lt;/STRONG&gt;. The corresponding Javascript code is correct (in this regard), though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll notice that the value of &lt;FONT face="courier new,courier"&gt;lcl_Byar&lt;/FONT&gt; in the first observation of WANT (after rounding to four decimals) does not exactly match the 0.644&lt;STRONG&gt;6&lt;/STRONG&gt; from the documentation. But SAS is -- of course! -- correct here. Unlike SAS's PROBIT function, the openepi source code computes the 97.5% quantile of the standard normal distribution as the square root of a hard-coded (!), &lt;STRONG&gt;rounded&lt;/STRONG&gt;&amp;nbsp;95% quantile of the chi-square distribution with one degree of freedom (3.841). Using this value the result would be 0.6445&lt;EM&gt;88&lt;/EM&gt;..., which explains the minor difference. Other than that, I used the formulas under "Byar Method" (p. 3) in the openepi documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that, for simplicity, I did not implement openepi's rule for the extreme cases n=0 or pt=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 18:34:11 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-04-17T18:34:11Z</dc:date>
    <item>
      <title>How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/639287#M78220</link>
      <description>&lt;P&gt;I am new to SAS and would like to solve I guess pretty simple task&lt;/P&gt;&lt;P&gt;I have the following data for incidences of the decease for each of 9 age groups for 17 years (2001-2017) and population in each age group&lt;/P&gt;&lt;P&gt;Here is data for 2001 year&lt;/P&gt;&lt;P&gt;Age&amp;nbsp; &amp;nbsp; &amp;nbsp; Count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Population&lt;/P&gt;&lt;P&gt;00-19&amp;nbsp; &amp;nbsp; &amp;nbsp; 46&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17945108&lt;/P&gt;&lt;P&gt;20-29&amp;nbsp; &amp;nbsp; &amp;nbsp; 150&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10460561&lt;/P&gt;&lt;P&gt;..............................................&lt;/P&gt;&lt;P&gt;85+&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;109&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1066463&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I need to calculate crude rate per 100000 with 95% CI intervals for all years using&amp;nbsp;exact Poisson method.&lt;/P&gt;&lt;P&gt;Year&amp;nbsp; &amp;nbsp;Crude rate&amp;nbsp; &amp;nbsp;Low&amp;nbsp; &amp;nbsp;High&lt;/P&gt;&lt;P&gt;2001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;&lt;P&gt;..............................................&lt;/P&gt;&lt;P&gt;2017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;&lt;P&gt;I think it could be done by using one of the SAS proc but I do not know which one and how.&lt;/P&gt;&lt;P&gt;Could anyone help me to solve this?&lt;/P&gt;&lt;P&gt;Thank you very much in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 10:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/639287#M78220</guid>
      <dc:creator>nastya</dc:creator>
      <dc:date>2020-04-12T10:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/639447#M78221</link>
      <description>&lt;P&gt;This may be the answer.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Confidence-intervals-for-rates-using-Poisson-distribution/td-p/25521" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Confidence-intervals-for-rates-using-Poisson-distribution/td-p/25521&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used this google search to find it&lt;/P&gt;
&lt;P&gt;poisson confidence limit site:sas.com&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 12:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/639447#M78221</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2020-04-13T12:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640454#M78263</link>
      <description>&lt;P&gt;I think the OP should also use some numeric representation of each group. For example, the median age in each group, or the center of each group (10, 25, 35, ....). Do you concur, Doc?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 14:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640454#M78263</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-04-16T14:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640493#M78265</link>
      <description>&lt;P&gt;Thank you for your response&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;I kind of know what the numeric result should be. Our previous statistician calculated for one set of data. I need to repeat calculation for another set.&lt;/P&gt;&lt;P&gt;I found that online tool openepi ( &lt;A href="https://www.openepi.com/PersonTime1/PersonTime1.htm" target="_blank" rel="noopener"&gt;https://www.openepi.com/PersonTime1/PersonTime1.htm&lt;/A&gt;) can produce rate and CI intervals exactly as in his original calculation.&lt;/P&gt;&lt;P&gt;Please see screenshot below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="screenshot.PNG" style="width: 822px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38354iE3C7ACE6E6CF8163/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot.PNG" alt="screenshot.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The number of cases I entered in that tool is total count of cases for all ages for 2001.&lt;/P&gt;&lt;P&gt;Person-time is total population for all ages for 2001.&lt;/P&gt;&lt;P&gt;Based on results above Poisson approx. and Fisher's exact test give me original result by just providing these two numbers above.&lt;/P&gt;&lt;P&gt;I prefer to use Poison approx. as I found in statistician notes he used exact Poisson method.&lt;/P&gt;&lt;P&gt;I would greatly appreciate your help in how to get this result in SAS just for one year. I can run then for all years&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 17:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640493#M78265</guid>
      <dc:creator>nastya</dc:creator>
      <dc:date>2020-04-16T17:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640800#M78291</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/318226"&gt;@nastya&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for sharing the link to openepi.com. This is interesting. Now it's easy to provide SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data
   (n=Number of cases, pt=person-time, ptu=person-time unit) */

data have;
input n pt ptu;
cards;
   5       25     10
4060 76513290 100000
;

/* Compute crude rate with two confidence intervals:
   exact Poisson CI and Byar's approximation */

%let alpha=0.05;

data want;
set have;
rate=n/pt*ptu;
lcl_exact=cinv(&amp;amp;alpha/2,2*n)/2/pt*ptu;
ucl_exact=cinv(1-&amp;amp;alpha/2,2*(n+1))/2/pt*ptu;
lcl_Byar=max(n*(1-1/(9*n)-probit(1-&amp;amp;alpha/2)/3*sqrt(1/n))**3/pt*ptu,0);
ucl_Byar=(n+1)*(1-1/(9*(n+1))+probit(1-&amp;amp;alpha/2)/3*sqrt(1/(n+1)))**3/pt*ptu;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                           lcl_       ucl_
   n          pt       ptu      rate      exact      exact     lcl_Byar    ucl_Byar

   5          25        10    2.00000    0.64939    4.66733     0.64454     4.66727
4060    76513290    100000    5.30627    5.14429    5.47205     5.14429     5.47205&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used your example and the example in the documentation&amp;nbsp;&lt;A href="https://www.openepi.com/PDFDocs/PersonTime1Doc.pdf" target="_blank" rel="noopener"&gt;https://www.openepi.com/PDFDocs/PersonTime1Doc.pdf&lt;/A&gt;, p. 2, in dataset HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the exact CI the openepi online calculator uses an iterative algorithm based on the Poisson probability function, whereas my SAS code uses the well-known relationship between the Poisson and chi-square distributions. Note that the formula for the lower confidence limit in the openepi documentation (see link above), p. 3, section "Fisher's exact test," is incorrect: The upper summation limit should read &lt;STRONG&gt;a-1&lt;/STRONG&gt;, not &lt;STRONG&gt;a&lt;/STRONG&gt;. The corresponding Javascript code is correct (in this regard), though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll notice that the value of &lt;FONT face="courier new,courier"&gt;lcl_Byar&lt;/FONT&gt; in the first observation of WANT (after rounding to four decimals) does not exactly match the 0.644&lt;STRONG&gt;6&lt;/STRONG&gt; from the documentation. But SAS is -- of course! -- correct here. Unlike SAS's PROBIT function, the openepi source code computes the 97.5% quantile of the standard normal distribution as the square root of a hard-coded (!), &lt;STRONG&gt;rounded&lt;/STRONG&gt;&amp;nbsp;95% quantile of the chi-square distribution with one degree of freedom (3.841). Using this value the result would be 0.6445&lt;EM&gt;88&lt;/EM&gt;..., which explains the minor difference. Other than that, I used the formulas under "Byar Method" (p. 3) in the openepi documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that, for simplicity, I did not implement openepi's rule for the extreme cases n=0 or pt=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 18:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640800#M78291</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-04-17T18:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate confidence interval for crude rate by using age group data by years</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640876#M78294</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;Thank you very much for your detailed explanation and source code.&lt;/P&gt;&lt;P&gt;That was exactly what I needed.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 22:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-calculate-confidence-interval-for-crude-rate-by-using-age/m-p/640876#M78294</guid>
      <dc:creator>nastya</dc:creator>
      <dc:date>2020-04-17T22:10:01Z</dc:date>
    </item>
  </channel>
</rss>

