Programming the statistical procedures from SAS

Proc Logistic categorical variable

Accepted Solution Solved
Reply
Contributor
Posts: 44
Accepted Solution

Proc Logistic categorical variable

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.

 

 


Accepted Solutions
Solution
‎08-09-2016 02:02 PM
Super User
Posts: 18,580

Re: Proc Logistic categorical variable


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


All Replies
Super User
Posts: 18,580

Re: Proc Logistic categorical variable

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. 

Contributor
Posts: 44

Re: Proc Logistic categorical variable

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. 

Solution
‎08-09-2016 02:02 PM
Super User
Posts: 18,580

Re: Proc Logistic categorical variable


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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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