BookmarkSubscribeRSS Feed
mconover
Quartz | Level 8

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;

3 REPLIES 3
SteveDenham
Jade | Level 19

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

mconover
Quartz | Level 8

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

SteveDenham
Jade | Level 19

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

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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