BookmarkSubscribeRSS Feed
kaimcqueen
Calcite | Level 5

This might be a silly question, but if I have four groups for my categorical variable and I want to get the full logistic model with odds ratios and model estimates such that each of the three comparisons are made in this way: 

 

A vs. B

A vs. C

A vs. D

 

How do I set up the SAS code in proc logistic to do this?

 

I only know of setting the reference group, but here the reference group changes (B, C, and D). 

 

I know I can set the reference group up separately as B and run the code and get the estimates for A vs. B, and then set the reference group up as C and get estimates for A vs. C...etc. But then I cannot get the intercept estimates for the model in which it is A vs. everything else. So, how can I get the full model of A vs. B, A vs. C, and A vs. D in one single run?  

 

Or will the intercept estimates of the model be the same as the intercept estimates of the model in which A is simply set up as the reference group (i.e., B vs. A, C vs. A, D vs. A)?

 

Please see attached PDF, as that picture is easier to understand. 

 

Thanks.

1 REPLY 1
Reeza
Super User

Welcome to the SAS forums. 

It does help if you post code so we can see what you've tried and what you're doing. 

 

You can get the results you'd like using the ODDSRATIO statement. Not sure it gets you all the way there and will depend a bit on your model, especially if you have other categorical variables. Take a look at the output from the code below and see how it works and if it solves your issue.

 

title 'Example 2. Modeling with Categorical Predictors';

data Neuralgia;
   input Treatment $ Sex $ Age Duration Pain $ @@;
   datalines;
P  F  68   1  No   B  M  74  16  No  P  F  67  30  No
P  M  66  26  Yes  B  F  67  28  No  B  F  77  16  No
A  F  71  12  No   B  F  72  50  No  B  F  76   9  Yes
A  M  71  17  Yes  A  F  63  27  No  A  F  69  18  Yes
B  F  66  12  No   A  M  62  42  No  P  F  64   1  Yes
A  F  64  17  No   P  M  74   4  No  A  F  72  25  No
P  M  70   1  Yes  B  M  66  19  No  B  M  59  29  No
A  F  64  30  No   A  M  70  28  No  A  M  69   1  No
B  F  78   1  No   P  M  83   1  Yes B  F  69  42  No
B  M  75  30  Yes  P  M  77  29  Yes P  F  79  20  Yes
A  M  70  12  No   A  F  69  12  No  B  F  65  14  No
B  M  70   1  No   B  M  67  23  No  A  M  76  25  Yes
P  M  78  12  Yes  B  M  77   1  Yes B  F  69  24  No
P  M  66   4  Yes  P  F  65  29  No  P  M  60  26  Yes
A  M  78  15  Yes  B  M  75  21  Yes A  F  67  11  No
P  F  72  27  No   P  F  70  13  Yes A  M  75   6  Yes
B  F  65   7  No   P  F  68  27  Yes P  M  68  11  Yes
P  M  67  17  Yes  B  M  70  22  No  A  M  65  15  No
P  F  67   1  Yes  A  M  67  10  No  P  F  72  11  Yes
A  F  74   1  No   B  M  80  21  Yes A  F  69   3  No
;

proc logistic data=Neuralgia;
   class Treatment Sex;
   model Pain= Treatment Sex Treatment*Sex Age Duration / expb;
   oddsratio treatment / diff=all;
run;

 


@kaimcqueen wrote:

This might be a silly question, but if I have four groups for my categorical variable and I want to get the full logistic model with odds ratios and model estimates such that each of the three comparisons are made in this way: 

 

A vs. B

A vs. C

A vs. D

 

How do I set up the SAS code in proc logistic to do this?

 

I only know of setting the reference group, but here the reference group changes (B, C, and D). 

 

I know I can set the reference group up separately as B and run the code and get the estimates for A vs. B, and then set the reference group up as C and get estimates for A vs. C...etc. But then I cannot get the intercept estimates for the model in which it is A vs. everything else. So, how can I get the full model of A vs. B, A vs. C, and A vs. D in one single run?  

 

Or will the intercept estimates of the model be the same as the intercept estimates of the model in which A is simply set up as the reference group (i.e., B vs. A, C vs. A, D vs. A)?

 

Please see attached PDF, as that picture is easier to understand. 

 

Thanks.


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2889 views
  • 0 likes
  • 2 in conversation