<?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: STATA logistic regression to SAS problem in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831081#M35608</link>
    <description>Do you just need a statement like this:&lt;BR /&gt;where week NE 2;</description>
    <pubDate>Tue, 30 Aug 2022 12:35:18 GMT</pubDate>
    <dc:creator>svh</dc:creator>
    <dc:date>2022-08-30T12:35:18Z</dc:date>
    <item>
      <title>STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831049#M35605</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;DIV class=""&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Might someone please help me with a problem I encounter when I attempt to convert STATA logistic regression to SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To keep the question simple, consider the logistic regression with variables:&lt;/P&gt;&lt;P&gt;response: binary 0/1&lt;/P&gt;&lt;P&gt;week: integer from 0 to 10&lt;/P&gt;&lt;P&gt;gender: M/F&lt;/P&gt;&lt;P&gt;age: continuous&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In STATA, the code would be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;logit response i.week i.gender age , or&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the data, I know that for some weeks, let's say week=2, there is 0 observation with response=1. Running the above code in STATA will result in a warning like the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;2.week != 0 predicts failure perfectly
2.week omitted and 24 obs not used&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;STATA will automatically handle "no event" or very rare event issue, and compute a meaningful odds ratio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we fit the same model in SAS using the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;proc genmod;
class week(ref='0') gender;
model response=week gender age / link=logit dist=bin;
lsmeans week gender / ilink diff exp;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We will get the warning of "Hessian matrix is not positive definite" due to the "no event" or very rare event issue. The resulting odds ratios for week are ridiculously large numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to re-create omitting the 24 obs in SAS like it does in STATA? I would really like to obtain the same outputs for understanding SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Aug 2022 08:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831049#M35605</guid>
      <dc:creator>hellorc</dc:creator>
      <dc:date>2022-08-30T08:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831081#M35608</link>
      <description>Do you just need a statement like this:&lt;BR /&gt;where week NE 2;</description>
      <pubDate>Tue, 30 Aug 2022 12:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831081#M35608</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2022-08-30T12:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831087#M35609</link>
      <description>&lt;P&gt;Thank you for your reply. Nope, after checking in STATA, there are ~600 obs with week=2, but only 24 are omitted in the model. Somehow there is a computed odds ratio for week=2 vs week=0 as 2.08 in STATA, while in SAS it's 10874311.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831087#M35609</guid>
      <dc:creator>hellorc</dc:creator>
      <dc:date>2022-08-30T12:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831088#M35610</link>
      <description>Thank you for your reply. Nope, after checking in STATA, there are ~600 obs with week=2, but only 24 are omitted in the model. Somehow there is a computed odds ratio for week=2 vs week=0 as 2.08 in STATA, while in SAS it's 10874311.</description>
      <pubDate>Tue, 30 Aug 2022 12:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831088#M35610</guid>
      <dc:creator>hellorc</dc:creator>
      <dc:date>2022-08-30T12:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831109#M35611</link>
      <description>&lt;P&gt;Suggestion:&lt;/P&gt;
&lt;P&gt;Provide a data set in the form of data step code so we can actually run your proc genmod code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, when you run code like this where you do not explicitly name the data set on the proc statement then SAS uses the last created data set. So there is a chance you may be running the procedure against a different data set than you think you are. While an occasionally useful feature for those that forget to provide the data set it is a best practice to always include the data=&amp;lt;use this data set&amp;gt; in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;proc genmod;
class week(ref='0') gender;
model response=week gender age / link=logit dist=bin;
lsmeans week gender / ilink diff exp;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 14:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831109#M35611</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-08-30T14:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: STATA logistic regression to SAS problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831179#M35617</link>
      <description>Thank you! It helped, I just figured out the issue!</description>
      <pubDate>Wed, 31 Aug 2022 01:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/STATA-logistic-regression-to-SAS-problem/m-p/831179#M35617</guid>
      <dc:creator>hellorc</dc:creator>
      <dc:date>2022-08-31T01:57:57Z</dc:date>
    </item>
  </channel>
</rss>

