<?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 95%CI and Incident rate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-95-CI-and-Incident-rate/m-p/713676#M220212</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you working on a clinical trial? If so, you must have access to the Statistical Analysis Plan (SAP), which is the primary source of information on the statistical methods you need to apply. If in doubt, discuss questions with the Trial Statistician, the author of the SAP. The table shell shown does not provide all details that would be required for precise answers. Your sample data are even more insufficient as they don't contain any time related information, without which neither incident rates nor the relative risks (as described in the table shell) can be computed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an outline of how I would expect the statistics in question to be calculated, based on my clinical research experience:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The 95% confidence intervals (CI) next to the percentages of participants who experienced certain adverse events are probably CIs for the binomial proportions within each treatment group. So, for example, if there were N=789 participants in group 1 and 6 of them died from "Myocardial infarction"&amp;nbsp;(preferred term), indicated by a 1/0 coded variable &lt;FONT face="courier new,courier"&gt;ae&lt;/FONT&gt;, you would use PROC FREQ with the BINOMIAL option of the TABLES statement to compute the CI:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
n=  6; ae=1; output;
n=783; ae=0; output;
run;

proc freq data=have;
weight n;
tables ae / binomial(level='1' correct);
output out=ci(keep=l_bin u_bin) binomial;
run;&lt;/CODE&gt;&lt;/PRE&gt;
Whether you should apply the continuity correction to the asymptotic CI (binomial option &lt;FONT face="courier new,courier"&gt;correct&lt;/FONT&gt;) or use the exact CI (variables &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;l_bin&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;u_bin&lt;/FONT&gt; in output dataset &lt;FONT face="courier new,courier"&gt;ci&lt;/FONT&gt;) or one of the other possible choices (see binomial option &lt;FONT face="courier new,courier"&gt;CL=&lt;/FONT&gt;) is one of those study-specific details that you need to clarify internally. Your PROC FREQ step will also contain a BY statement defining treatment group, system organ class (SOC) and preferred term (PT) as BY variables so that all calculations can be done in a single step (on an appropriately structured input dataset).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The incident rates can be calculated in a DATA step using a formula like&lt;BR /&gt;
&lt;PRE&gt;&lt;EM&gt;incident_rate&lt;/EM&gt; = &lt;EM&gt;number_of_subjects&lt;/EM&gt; / &lt;EM&gt;total_years_at_risk&lt;/EM&gt; * 100&lt;/PRE&gt;
where &lt;FONT face="courier new,courier"&gt;&lt;EM&gt;number_of_subjects&lt;/EM&gt;&lt;/FONT&gt; is the number of participants, say, in group 1 who experienced the adverse event (AE) in question (or &lt;EM&gt;any&lt;/EM&gt;&amp;nbsp;fatal AE of a particular system organ class [SOC] or any fatal AE, respectively) and &lt;FONT face="courier new,courier"&gt;&lt;EM&gt;total_years_at_risk&lt;/EM&gt;&lt;/FONT&gt; is the sum of all times at risk (in years) of the participants of that group. Typically, the time at risk for an individual subject is defined as the time from treatment start to AE onset or, if the subject did not experience the AE, to end of follow-up. Again, the details are study-specific.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The Poisson regression model mentioned in the table shell can be calculated using PROC GENMOD. Based on an input dataset containing the treatment group, the logarithm of follow-up time and the number of AEs in question (0 or 1 because they are fatal AEs) for each participant this might look something like this:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have2;
call streaminit(27182818);
do group=1 to 2;
  do _n_=1 to 789;
    fu_time=rand('uniform');
    log_fu_time=log(fu_time);
    num_ae=rand('bern',fu_time*exp(-3.45+0.67*(group=1)));
    output;
  end;
end;
run;

/* Perform Poisson regression */

proc genmod data=have2;
class group(ref='2' param=ref);
model num_ae=group / d=poisson offset=log_fu_time;
estimate 'relrisk' group 1;
ods output Estimates=relrisk(keep=Mean:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
As for the other items, BY-group processing would be used to perform the calculations for all PTs, SOCs and overall in one PROC GENMOD step. Again, details are study-specific. For example, there is evidence that a &lt;EM&gt;modified&lt;/EM&gt; Poisson regression model &lt;A href="https://academic.oup.com/aje/article-pdf/159/7/702/159936/kwh090.pdf" target="_blank" rel="noopener"&gt;proposed by&amp;nbsp;Guangyong Zou 2004&lt;/A&gt; (using a robust error variance) yields a more appropriate (less conservative) confidence interval for the relative risk. See, e.g., &lt;A href="https://support.sas.com/kb/23/003.html" target="_blank"&gt;https://support.sas.com/kb/23/003.html&lt;/A&gt; or&amp;nbsp;&lt;A href="https://www.lexjansen.com/wuss/2013/81_Paper.pdf" target="_blank" rel="noopener"&gt;Proper Estimation of Relative Risk Using PROC GENMOD in Population Studies&lt;/A&gt; for more details including the (fairly simple) implementation by means of a REPEATED statement in the PROC GENMOD step.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sun, 24 Jan 2021 13:20:22 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-01-24T13:20:22Z</dc:date>
    <item>
      <title>How to calculate 95%CI and Incident rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-95-CI-and-Incident-rate/m-p/713563#M220159</link>
      <description>&lt;P&gt;Please help!&amp;nbsp; Trying my luck here.&amp;nbsp; I'm not very knowledgable in statistics nor SAS. I am giving a Table program but have no clue where to start to calculate 95% CI, Incident Rate, and Relative Risk (95%)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. CI95% - do I calculate 95%CI between the two treatment groups ("group1" , "group2")? I wouldn't know where else you can get lower/higher limits solely based"System Organ Class" &amp;amp; "Preferred Term xx"&amp;nbsp; &amp;nbsp;counts.&lt;/P&gt;&lt;P&gt;2. Incident Rate-&amp;nbsp; is there a function I can use to get this value ("event incident rate per 100 person-years")?&lt;/P&gt;&lt;P&gt;3. Relative Risk(95%)- no idea how how i would incorporate the two 95%CI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table shell:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_0-1611377468120.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53824iD3F7CD3D590EFF1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_0-1611377468120.png" alt="HitmonTran_0-1611377468120.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data:&lt;/P&gt;&lt;PRE&gt;subject       system_organ_class     preferred_term     treatment_group
bob            lungs                 breathe            1
bob            lungs                 air                1
joe            lungs                 breath             1
joe            heart                 pump               1
ronnie         brain                 hub                2&lt;/PRE&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2021 05:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-95-CI-and-Incident-rate/m-p/713563#M220159</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-01-23T05:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate 95%CI and Incident rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-95-CI-and-Incident-rate/m-p/713676#M220212</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/111564"&gt;@HitmonTran&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you working on a clinical trial? If so, you must have access to the Statistical Analysis Plan (SAP), which is the primary source of information on the statistical methods you need to apply. If in doubt, discuss questions with the Trial Statistician, the author of the SAP. The table shell shown does not provide all details that would be required for precise answers. Your sample data are even more insufficient as they don't contain any time related information, without which neither incident rates nor the relative risks (as described in the table shell) can be computed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an outline of how I would expect the statistics in question to be calculated, based on my clinical research experience:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The 95% confidence intervals (CI) next to the percentages of participants who experienced certain adverse events are probably CIs for the binomial proportions within each treatment group. So, for example, if there were N=789 participants in group 1 and 6 of them died from "Myocardial infarction"&amp;nbsp;(preferred term), indicated by a 1/0 coded variable &lt;FONT face="courier new,courier"&gt;ae&lt;/FONT&gt;, you would use PROC FREQ with the BINOMIAL option of the TABLES statement to compute the CI:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
n=  6; ae=1; output;
n=783; ae=0; output;
run;

proc freq data=have;
weight n;
tables ae / binomial(level='1' correct);
output out=ci(keep=l_bin u_bin) binomial;
run;&lt;/CODE&gt;&lt;/PRE&gt;
Whether you should apply the continuity correction to the asymptotic CI (binomial option &lt;FONT face="courier new,courier"&gt;correct&lt;/FONT&gt;) or use the exact CI (variables &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;l_bin&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;x&lt;/STRONG&gt;u_bin&lt;/FONT&gt; in output dataset &lt;FONT face="courier new,courier"&gt;ci&lt;/FONT&gt;) or one of the other possible choices (see binomial option &lt;FONT face="courier new,courier"&gt;CL=&lt;/FONT&gt;) is one of those study-specific details that you need to clarify internally. Your PROC FREQ step will also contain a BY statement defining treatment group, system organ class (SOC) and preferred term (PT) as BY variables so that all calculations can be done in a single step (on an appropriately structured input dataset).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The incident rates can be calculated in a DATA step using a formula like&lt;BR /&gt;
&lt;PRE&gt;&lt;EM&gt;incident_rate&lt;/EM&gt; = &lt;EM&gt;number_of_subjects&lt;/EM&gt; / &lt;EM&gt;total_years_at_risk&lt;/EM&gt; * 100&lt;/PRE&gt;
where &lt;FONT face="courier new,courier"&gt;&lt;EM&gt;number_of_subjects&lt;/EM&gt;&lt;/FONT&gt; is the number of participants, say, in group 1 who experienced the adverse event (AE) in question (or &lt;EM&gt;any&lt;/EM&gt;&amp;nbsp;fatal AE of a particular system organ class [SOC] or any fatal AE, respectively) and &lt;FONT face="courier new,courier"&gt;&lt;EM&gt;total_years_at_risk&lt;/EM&gt;&lt;/FONT&gt; is the sum of all times at risk (in years) of the participants of that group. Typically, the time at risk for an individual subject is defined as the time from treatment start to AE onset or, if the subject did not experience the AE, to end of follow-up. Again, the details are study-specific.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The Poisson regression model mentioned in the table shell can be calculated using PROC GENMOD. Based on an input dataset containing the treatment group, the logarithm of follow-up time and the number of AEs in question (0 or 1 because they are fatal AEs) for each participant this might look something like this:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have2;
call streaminit(27182818);
do group=1 to 2;
  do _n_=1 to 789;
    fu_time=rand('uniform');
    log_fu_time=log(fu_time);
    num_ae=rand('bern',fu_time*exp(-3.45+0.67*(group=1)));
    output;
  end;
end;
run;

/* Perform Poisson regression */

proc genmod data=have2;
class group(ref='2' param=ref);
model num_ae=group / d=poisson offset=log_fu_time;
estimate 'relrisk' group 1;
ods output Estimates=relrisk(keep=Mean:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
As for the other items, BY-group processing would be used to perform the calculations for all PTs, SOCs and overall in one PROC GENMOD step. Again, details are study-specific. For example, there is evidence that a &lt;EM&gt;modified&lt;/EM&gt; Poisson regression model &lt;A href="https://academic.oup.com/aje/article-pdf/159/7/702/159936/kwh090.pdf" target="_blank" rel="noopener"&gt;proposed by&amp;nbsp;Guangyong Zou 2004&lt;/A&gt; (using a robust error variance) yields a more appropriate (less conservative) confidence interval for the relative risk. See, e.g., &lt;A href="https://support.sas.com/kb/23/003.html" target="_blank"&gt;https://support.sas.com/kb/23/003.html&lt;/A&gt; or&amp;nbsp;&lt;A href="https://www.lexjansen.com/wuss/2013/81_Paper.pdf" target="_blank" rel="noopener"&gt;Proper Estimation of Relative Risk Using PROC GENMOD in Population Studies&lt;/A&gt; for more details including the (fairly simple) implementation by means of a REPEATED statement in the PROC GENMOD step.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 24 Jan 2021 13:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-95-CI-and-Incident-rate/m-p/713676#M220212</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-01-24T13:20:22Z</dc:date>
    </item>
  </channel>
</rss>

