<?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 How can I write code for Poisson regression with counts? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731278#M35483</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of five age groups each has &amp;nbsp;Person-years for smokers and nonsmokers, and Coronary Deaths for smokers and nonsmokers. I need to figure out the codes for Poisson regression to the two below problems:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1. Fit a Poisson regression with &lt;STRONG&gt;count&lt;/STRONG&gt; of coronary deaths as response variable, find the risk ratio (smoker vs. nonsmoker) adjusted for age.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Fit a Poisson regression with &lt;STRONG&gt;person-years rate &lt;/STRONG&gt;of coronary deaths as response variable, find the risk ratio (smoker vs. nonsmoker) adjusted for age.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;For problem 1 I have tried the following code.&amp;nbsp;However, I think it is wrong since i need to count the deaths not person_years !! (nonsmokers=0) (smokers=1)&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;data CORONARY_DEATHS;
input age smoke count p_time; 
log_time=log(p_time); 
datalines; 
35 0 2 18793 
35 1 32 52407
45 0 12 10673
45 1 104 43248 
55 0 28 5710 
55 1 206 12663 
65 0 28 2585
65 1 186 12663
75 0 31 1462
75 1 102 5317
;
run;

data CORONARY_DEATHS;
input age smoke count p_time; 
log_time=log(p_time); 
datalines; 
35 0 2 18793 
35 1 32 52407
45 0 12 10673
45 1 104 43248 
55 0 28 5710 
55 1 206 12663 
65 0 28 2585
65 1 186 12663
75 0 31 1462
75 1 102 5317
;
run;

data CORONARY_DEATHS; set CORONARY_DEATHS; 
AGE55=0; if AGE=55 then AGE55=1; 
AGE65=0; if AGE=65 then AGE65=1;
 run;
proc genmod data=CORONARY_DEATHS; 
model count=smoke AGE55 AGE65/dist=poi link=log offset=log_time; run;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;PS: I am a healthcare student taking&amp;nbsp;biostatistics and SAS is part of the course. Therefore, little&amp;nbsp;&lt;/SPAN&gt;knowledge is what I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Apr 2021 20:30:41 GMT</pubDate>
    <dc:creator>Nouf2</dc:creator>
    <dc:date>2021-04-04T20:30:41Z</dc:date>
    <item>
      <title>How can I write code for Poisson regression with counts?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731278#M35483</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of five age groups each has &amp;nbsp;Person-years for smokers and nonsmokers, and Coronary Deaths for smokers and nonsmokers. I need to figure out the codes for Poisson regression to the two below problems:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1. Fit a Poisson regression with &lt;STRONG&gt;count&lt;/STRONG&gt; of coronary deaths as response variable, find the risk ratio (smoker vs. nonsmoker) adjusted for age.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Fit a Poisson regression with &lt;STRONG&gt;person-years rate &lt;/STRONG&gt;of coronary deaths as response variable, find the risk ratio (smoker vs. nonsmoker) adjusted for age.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;For problem 1 I have tried the following code.&amp;nbsp;However, I think it is wrong since i need to count the deaths not person_years !! (nonsmokers=0) (smokers=1)&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;data CORONARY_DEATHS;
input age smoke count p_time; 
log_time=log(p_time); 
datalines; 
35 0 2 18793 
35 1 32 52407
45 0 12 10673
45 1 104 43248 
55 0 28 5710 
55 1 206 12663 
65 0 28 2585
65 1 186 12663
75 0 31 1462
75 1 102 5317
;
run;

data CORONARY_DEATHS;
input age smoke count p_time; 
log_time=log(p_time); 
datalines; 
35 0 2 18793 
35 1 32 52407
45 0 12 10673
45 1 104 43248 
55 0 28 5710 
55 1 206 12663 
65 0 28 2585
65 1 186 12663
75 0 31 1462
75 1 102 5317
;
run;

data CORONARY_DEATHS; set CORONARY_DEATHS; 
AGE55=0; if AGE=55 then AGE55=1; 
AGE65=0; if AGE=65 then AGE65=1;
 run;
proc genmod data=CORONARY_DEATHS; 
model count=smoke AGE55 AGE65/dist=poi link=log offset=log_time; run;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;PS: I am a healthcare student taking&amp;nbsp;biostatistics and SAS is part of the course. Therefore, little&amp;nbsp;&lt;/SPAN&gt;knowledge is what I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Apr 2021 20:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731278#M35483</guid>
      <dc:creator>Nouf2</dc:creator>
      <dc:date>2021-04-04T20:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write code for Poisson regression with counts?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731333#M35484</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You said:&amp;nbsp;&lt;SPAN&gt;I think it is wrong since I need to count the deaths not person_years !!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I do not understand why you think you have the wrong response (variable). You have specified the correct target variable in your model statement. And you are quite well aligning with this example (maybe you used it as a basis for your code?):&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS/STAT® 15.2 User's Guide --&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;The GENMOD Procedure --&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Poisson Regression&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_genmod_gettingstarted01.htm&amp;amp;docsetVersion=15.2&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_genmod_gettingstarted01.htm&amp;amp;docsetVersion=15.2&amp;amp;locale=en&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Note there exist many SAS papers on Poisson regression (with SAS) and you can also use the&amp;nbsp;COUNTREG procedure (count regression SAS/ETS) to fit a Poisson regression.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 10:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731333#M35484</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-05T10:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I write code for Poisson regression with counts?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731334#M35485</link>
      <description>&lt;A href="http://support.sas.com/kb/24/188.html" target="_blank"&gt;http://support.sas.com/kb/24/188.html&lt;/A&gt;</description>
      <pubDate>Mon, 05 Apr 2021 10:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-can-I-write-code-for-Poisson-regression-with-counts/m-p/731334#M35485</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-05T10:39:04Z</dc:date>
    </item>
  </channel>
</rss>

