<?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: Incorrect reference level defined in class statement of PROC LOGISTIC in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522489#M73444</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251892"&gt;@B_bonna&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, thank you very much for providing test data in the form of a data step and your PROC LOGISTIC code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run your code I get this output (showing only parts relevant for your question):&lt;/P&gt;
&lt;PRE&gt;              Model Information

Data Set                      WORK.HAVE
Response Variable             var2

          Response Profile

 Ordered                      Total
   Value         var2     Frequency

       1            1          2164
       2            2           442

Probability modeled is var2=1.


   Class Level Information

                      Design
Class     Value     Variables

var1      0                 1
          1                 0

                    Analysis of Maximum Likelihood Estimates

                                 Standard          Wald
Parameter      DF    Estimate       Error    Chi-Square    Pr &amp;gt; ChiSq    Exp(Est)

Intercept       1      1.4170      0.0745      362.0330        &amp;lt;.0001       4.125
var1      0     1      0.3213      0.1046        9.4373        0.0021       1.379


             Odds Ratio Estimates

                  Point          95% Wald
Effect         Estimate      Confidence Limits

var1 0 vs 1       1.379       1.123       1.693&lt;/PRE&gt;
&lt;P&gt;This is consistent with your PROC LOGISTIC, CLASS and MODEL statements: Level '1' of variable VAR1 is used as the reference level and the probability modeled is that of VAR2=1. In particular, the odds ratio is exactly what you want (actually it's computed as &lt;FONT face="courier new,courier"&gt;(1240/218)/(924/224)&lt;/FONT&gt;, of course with the same result) and it's also consistent with PROC FREQ output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
tables var1*var2 / or nopercent norow nocol;
weight freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Table of var1 by var2

var1      var2

Frequency|       1|       2|  Total
---------+--------+--------+
       0 |   1240 |    218 |   1458
---------+--------+--------+
       1 |    924 |    224 |   1148
---------+--------+--------+
Total        2164      442     2606


Statistics for Table of var1 by var2

                  Odds Ratio and Relative Risks

Statistic                        Value       95% Confidence Limits
------------------------------------------------------------------
Odds Ratio                      1.3789        1.1233        1.6927&lt;/PRE&gt;
&lt;P&gt;Note that in your contingency table the variable names are exchanged. Also, replacing &lt;FONT face="courier new,courier"&gt;ref='1'&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;ref=first&lt;/FONT&gt; changes the reference level from 1 to 0 because "first" means the "first ordered level". Then you would indeed obtain the reciprocal odds ratio, i.e. 0.725.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 11:41:43 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-12-19T11:41:43Z</dc:date>
    <item>
      <title>Incorrect reference level defined in class statement of PROC LOGISTIC</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522428#M73442</link>
      <description>&lt;DIV class="post-text"&gt;&lt;P&gt;I am running a &lt;CODE&gt;PROC LOGISTIC&lt;/CODE&gt; statement, defining the reference level under the &lt;CODE&gt;class&lt;/CODE&gt; as:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data have;
input var1 var2 freq;
cards;
0 1 1240
1 1 924
0 2 218
1 2 224
;;;;

proc logistic data=have;
class var1 (param=ref ref='1');
model var2 = var1 / expb;
freq freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My contingency table looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;           Var1  
Var2     | 1      2   
---------------------- 
   0     | 1240   218
   1     | 924    224 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Where I state the reference level of Var1 to be &lt;CODE&gt;first&lt;/CODE&gt;, I mean it to be 1. This after all is the first level of variable &lt;CODE&gt;Var1&lt;/CODE&gt;. The odds ratio that is given however, is 0.725. That would imply the second level, 2, is taken as reference group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;odds ratio given:&lt;/P&gt;&lt;P&gt;(924/1240)/(224/218)= 0.725&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;intended:&lt;/P&gt;&lt;P&gt;(224/218)/(924/1240)= 1.379&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a matter of definition of reference group, or is the program not defining the reference level correctly?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Dec 2018 05:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522428#M73442</guid>
      <dc:creator>B_bonna</dc:creator>
      <dc:date>2018-12-19T05:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect reference level defined in class statement of PROC LOGISTIC</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522489#M73444</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251892"&gt;@B_bonna&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, thank you very much for providing test data in the form of a data step and your PROC LOGISTIC code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run your code I get this output (showing only parts relevant for your question):&lt;/P&gt;
&lt;PRE&gt;              Model Information

Data Set                      WORK.HAVE
Response Variable             var2

          Response Profile

 Ordered                      Total
   Value         var2     Frequency

       1            1          2164
       2            2           442

Probability modeled is var2=1.


   Class Level Information

                      Design
Class     Value     Variables

var1      0                 1
          1                 0

                    Analysis of Maximum Likelihood Estimates

                                 Standard          Wald
Parameter      DF    Estimate       Error    Chi-Square    Pr &amp;gt; ChiSq    Exp(Est)

Intercept       1      1.4170      0.0745      362.0330        &amp;lt;.0001       4.125
var1      0     1      0.3213      0.1046        9.4373        0.0021       1.379


             Odds Ratio Estimates

                  Point          95% Wald
Effect         Estimate      Confidence Limits

var1 0 vs 1       1.379       1.123       1.693&lt;/PRE&gt;
&lt;P&gt;This is consistent with your PROC LOGISTIC, CLASS and MODEL statements: Level '1' of variable VAR1 is used as the reference level and the probability modeled is that of VAR2=1. In particular, the odds ratio is exactly what you want (actually it's computed as &lt;FONT face="courier new,courier"&gt;(1240/218)/(924/224)&lt;/FONT&gt;, of course with the same result) and it's also consistent with PROC FREQ output:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
tables var1*var2 / or nopercent norow nocol;
weight freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Table of var1 by var2

var1      var2

Frequency|       1|       2|  Total
---------+--------+--------+
       0 |   1240 |    218 |   1458
---------+--------+--------+
       1 |    924 |    224 |   1148
---------+--------+--------+
Total        2164      442     2606


Statistics for Table of var1 by var2

                  Odds Ratio and Relative Risks

Statistic                        Value       95% Confidence Limits
------------------------------------------------------------------
Odds Ratio                      1.3789        1.1233        1.6927&lt;/PRE&gt;
&lt;P&gt;Note that in your contingency table the variable names are exchanged. Also, replacing &lt;FONT face="courier new,courier"&gt;ref='1'&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;ref=first&lt;/FONT&gt; changes the reference level from 1 to 0 because "first" means the "first ordered level". Then you would indeed obtain the reciprocal odds ratio, i.e. 0.725.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 11:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522489#M73444</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-12-19T11:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect reference level defined in class statement of PROC LOGISTIC</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522613#M73447</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251892"&gt;@B_bonna&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class="post-text"&gt;
&lt;P&gt;I am running a &lt;CODE&gt;PROC LOGISTIC&lt;/CODE&gt; statement, defining the reference level under the &lt;CODE&gt;class&lt;/CODE&gt; as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;data have;
input var1 var2 freq;
cards;
0 1 1240
1 1 924
0 2 218
1 2 224
;;;;

proc logistic data=have;
class var1 (param=ref &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;ref='1'&lt;/STRONG&gt;&lt;/FONT&gt;);
model var2 = var1 / expb;
freq freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My contingency table looks like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;           Var1  
Var2     | 1      2   
---------------------- 
   0     | 1240   218
   1     | 924    224 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Where I state the reference level of Var1 to be &lt;CODE&gt;first&lt;/CODE&gt;, I mean it to be 1. This after all is the first level of variable &lt;CODE&gt;Var1&lt;/CODE&gt;.&lt;/FONT&gt; The odds ratio that is given however, is 0.725. That would imply the second level, 2, is taken as reference group.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;odds ratio given:&lt;/P&gt;
&lt;P&gt;(924/1240)/(224/218)= 0.725&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;intended:&lt;/P&gt;
&lt;P&gt;(224/218)/(924/1240)= 1.379&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this a matter of definition of reference group, or is the program not defining the reference level correctly?&lt;/P&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Except your code doesn't state first, it states the reference level is 1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 16:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Incorrect-reference-level-defined-in-class-statement-of-PROC/m-p/522613#M73447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-19T16:15:48Z</dc:date>
    </item>
  </channel>
</rss>

