Contributor
Posts: 50

# How do I use the CONTRAST statement in PROC LOGISTIC to get an odds ratio?

I have data containing counts across the following three variables.  Possible values are noted below (3 potential values each).

1. EDUCATION_LEVEL
• "HIGH" - Referring to high school (referent)
• "LESS" - Referring to less than high school
• "COLLEGE" - Referring to college students
2. REGION
• WEST (referent)
• MIDWEST
• EAST
3. AGREEMENT (with a given statement - NOTE THIS IS AN ORDINAL VARIABLE)
• DISAGREE
• NEUTRAL
• AGREE

I am trying to create a logistic regression model to fit this data in order to estimate the odds ratio comparing the "COLLEGE" and "LESS" categories of my EDUCATION_LEVEL variable, adjusting for variation in region.

Honestly any sort of statistical test indicating the difference between these two categories could be useful.  I just can't seem to get it to do anything useful for me.  I feel like I've been messing with this for way too long and am thinking of scrapping the whole thing

When I run this code, all I get is odds ratios comparing all the specific permutations of all three variables but I can't figure out how to write a contrast statement to give me a ratio that's pooled across the regions.

PROC LOGISTIC DATA=WORK.EDUC ORDER=data;

FREQ COUNT;

CLASS EDUCATION_LEVEL (ref='LESS') REGION (ref='WEST') / param=reference order=FORMATTED;

MODEL AGREEMENT = EDUCATION_LEVEL REGION EDUCATION_LEVEL*REGION / link=clogit

SCALE=NONE AGGREGATE ;

FORMAT EDUCATION_LEVEL EDUCATION_LEVEL. REGION REGION.;

ODDSRATIO EDUCATION_LEVEL / CL=BOTH DIFF=REF  ;

title "main effects partial proportional odds model" ;

CONTRAST 'COLLEGE vs LESS' EDUCATION_LEVEL 2/ ESTIMATE=exp ;

RUN;

Posts: 2,655

## Re: How do I use the CONTRAST statement in PROC LOGISTIC to get an odds ratio?

If you are on version 9.22 or STAT12.1, take a look at the LSMESTIMATE statement.  By coding up the specifics for your class levels properly, and using the EXP option, you should be able to get the odds ratios you want.  Let us know if it works (because I'm kind of spitballing on this).

Steve Denham

Contributor
Posts: 50

## Re: How do I use the CONTRAST statement in PROC LOGISTIC to get an odds ratio?

sorry couldn't get that to work at all.  I don't really know how to use that statement though.

Posts: 2,655

## Re: How do I use the CONTRAST statement in PROC LOGISTIC to get an odds ratio?

Try the following:

PROC LOGISTIC DATA=WORK.EDUC ORDER=data;

FREQ COUNT;

CLASS EDUCATION_LEVEL (ref='LESS') REGION (ref='WEST') / param=reference order=FORMATTED;

MODEL AGREEMENT = EDUCATION_LEVEL REGION EDUCATION_LEVEL*REGION / link=clogit

SCALE=NONE AGGREGATE ;

FORMAT EDUCATION_LEVEL EDUCATION_LEVEL. REGION REGION.;

LSMEANS EDUCATION_LEVEL*REGION/E;

RUN:

This should give the means on the cumulative logit scale, and the /e option will give the coefficients, in order, for each of these means.  You could then consolidate them as you want to get the comparisons.  An example might be:

LSMESTIMATE education_level*region 'college vs less, averaged over regions' <INSERT APPROPRIATE VALUES HERE>;

where the appropriate values would look something like 1 0 -1 1 0 -1 1 0 -1 (divisor=3)/exp.  I put this in a separate place, because I am not sure how everything will sort without running code.  It just looks like there are nine estimated values, and this would average over regions.  Order is critical however, which is why I added the /e option to the lsmeans statement.

Steve Denham

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