BookmarkSubscribeRSS Feed
B_bonna
Calcite | Level 5

I am running a PROC LOGISTIC statement, defining the reference level under the class as:

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;

My contingency table looks like:

           Var1  
Var2     | 1      2   
---------------------- 
   0     | 1240   218
   1     | 924    224 

Where I state the reference level of Var1 to be first, I mean it to be 1. This after all is the first level of variable Var1. The odds ratio that is given however, is 0.725. That would imply the second level, 2, is taken as reference group.

 

odds ratio given:

(924/1240)/(224/218)= 0.725

 

intended:

(224/218)/(924/1240)= 1.379

 

Is this a matter of definition of reference group, or is the program not defining the reference level correctly?

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @B_bonna and welcome to the SAS Support Communities!

 

First of all, thank you very much for providing test data in the form of a data step and your PROC LOGISTIC code.

 

When I run your code I get this output (showing only parts relevant for your question):

              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 > ChiSq    Exp(Est)

Intercept       1      1.4170      0.0745      362.0330        <.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

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 (1240/218)/(924/224), of course with the same result) and it's also consistent with PROC FREQ output:

proc freq data=have;
tables var1*var2 / or nopercent norow nocol;
weight freq;
run;
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

Note that in your contingency table the variable names are exchanged. Also, replacing ref='1' with ref=first 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.

Reeza
Super User

@B_bonna wrote:

I am running a PROC LOGISTIC statement, defining the reference level under the class as:

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;

My contingency table looks like:

           Var1  
Var2     | 1      2   
---------------------- 
   0     | 1240   218
   1     | 924    224 

Where I state the reference level of Var1 to be first, I mean it to be 1. This after all is the first level of variable Var1. The odds ratio that is given however, is 0.725. That would imply the second level, 2, is taken as reference group.

 

odds ratio given:

(924/1240)/(224/218)= 0.725

 

intended:

(224/218)/(924/1240)= 1.379

 

Is this a matter of definition of reference group, or is the program not defining the reference level correctly?


Except your code doesn't state first, it states the reference level is 1. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 973 views
  • 2 likes
  • 3 in conversation