## Estimating O.R.s for interaction terms bt continuous & categorical variables in Proc Logistic

Occasional Contributor
Posts: 18

# Estimating O.R.s for interaction terms bt continuous & categorical variables in Proc Logistic

[ Edited ]

I am trying to estimate odds ratios for interaction terms in a logistic regression using v9.4. I've found this article, http://support.sas.com/kb/24/455.html, but can't find an explanation for how to determine which numbers to enter into the matrix (the 1s, 0s, -1s in the example) in the estimate statement to pull what I want. I am specifcially having difficulty figuring out how to pull for an interaction between a continuous variable (peervicadd) and a categorical one (percschsafe). For good measure, here's my code:

Proc logistic data=secondyp.lgbq;

class race(ref="5" param=ref) sex(ref="1" param=ref) percschsafe(param=ref ref="0");

estimate "Peer Victimization" peervicadd 1/exp cl;

estimate "Perception of School Safety (No)" percschsafe 0 /exp cl;

estimate "Perception of School Safety (Yes)" percschsafe 1 /exp cl;

Estimate "Peer Victimization x Perceptions of School Safety (No)" percschsafe*peervicadd 0 1 /exp cl;

Estimate "Peer Victimization x Perceptions of School Safety (Yes)" percschsafe*peervicadd 1 1 /exp cl;

Run;

Adding to the mystery, I keep getting this message in the log:

WARNING: More coefficients than levels specified for effect PeerVicAd*PercSchSaf.  Some

coefficients will be ignored.

WARNING: More coefficients than levels specified for effect PeerVicAd*PercSchSaf.  Some

coefficients will be ignored.

If someone could point me to a reference to see what #'s line up to the various columns in the Estimate statement, I would be very appreciative.

Thanks,
Andrew

Super User
Posts: 20,765

## Re: Estimating odds ratios for interaction terms in Proc Logistic

Use the ODDSRATIO statement instead, a bit easier to navigate in my opinion.

You're looking for the interaction between a categorical and continuous variable so you may want to specify levels, it chooses the average by default.

``````proc logistic data=sashelp.heart;
class sex ;
model status = ageatstart height weight sex weight*sex ;
oddsratio sex;
run;
``````
Occasional Contributor
Posts: 18

## Re: Estimating odds ratios for interaction terms in Proc Logistic

Thanks for your reply. I tried to use an oddsratio statement, but I got results that didn't make sense -- the OR's didn't cross 1 even though the interaction term wasn't significant. Is it pulling the interaction term or the predictor variable (sex in your example)?
Super User
Posts: 20,765

## Re: Estimating odds ratios for interaction terms in Proc Logistic

The OR's shouldn't cross 1 if the term is insignificant.

When you have an interaction term, you can only look at a 'conditional' oddsratio of your variable.

Ie Sex at average weight of 158lbs

Occasional Contributor
Posts: 18

## Re: Estimating odds ratios for interaction terms in Proc Logistic

That makes sense; thank you. I'd like to pull an estimate for the interaction term itself (i.e. in your example, sex*weight). Is that possible with the oddsratio statment?

Super User
Posts: 20,765

## Re: Estimating odds ratios for interaction terms in Proc Logistic

What are you expecting as output for that?

If they were both categorical you could look at it for all levels, but since one is continuous you need to pick one or several values for weight to consider.

Discussion stats
• 5 replies
• 360 views
• 0 likes
• 2 in conversation