BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TJ87
Obsidian | Level 7

Hello,

 

I'm running Proc Logistic for a continuous variable that I have categorized as quartiles. I seem to get two different answers for the odds ratio estimate of Quartile 4 vs Quartile 1 depending on how I code the variable. The first (standard) program is:

 

proc logistic data=have;
class var_quartile (ref="1") /param=ref;
model outcome (event="1")= var_quartile;
run;

 

In a second program, I re-coded the predictor as a binary indicator:

 

data new;

set have;

if var_quartile=4 then var_new=1;

else if var_quartile=1 then var_new=0;

else var_new=.;

run;

 

proc logistic data=new;
class var_new (ref="0") /param=ref;
model outcome (event="1")= var_new;
run;

 

Could someone please tell me why SAS gives me two different answers for the same comparion? Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@TJ87 wrote:

Hi Reeza,

 

but I'd like to be able to use a binary variable for the comparison of interest. 


The OddsRatio doesn't give you the correct comparison?

 

proc logistic data=have;
class var_quartile (ref="1") /param=ref;
model outcome (event="1")= var_quartile; 
oddsratio var_quartile;
run;

View solution in original post

3 REPLIES 3
Reeza
Super User

What happens if you run your model as:

 

proc logistic data=have;
where var_quartile in (1, 4);
class var_quartile (ref="1") /param=ref;
model outcome (event="1")= var_quartile; 
run;

My guess - a rusty one - is the second model totally excludes the var_new with missing and that's affecting the variance estimates. 

TJ87
Obsidian | Level 7

Hi Reeza,

 

That syntax gives me the same wrong answer as if I had used the indicator variable. I've used dummy variables (Quartile2, Quartile3, Quartile4) to calculate the correct answer, but I'd like to be able to use a binary variable for the comparison of interest. Thanks. 

Reeza
Super User

@TJ87 wrote:

Hi Reeza,

 

but I'd like to be able to use a binary variable for the comparison of interest. 


The OddsRatio doesn't give you the correct comparison?

 

proc logistic data=have;
class var_quartile (ref="1") /param=ref;
model outcome (event="1")= var_quartile; 
oddsratio var_quartile;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1860 views
  • 0 likes
  • 2 in conversation