BookmarkSubscribeRSS Feed
sebai
Obsidian | Level 7

I want to use contrast in proc logistic, but I don’t seem to clearly understand where the numbers in the contrast statement come from.

My model include:

  • Region: variable with 3 categories (1-Sud; 2-GAE; 3-GAO)
  • Land access: variable with 2 categories (‘NO’; ‘Wi’)
  • Season: variable with 2 categories (Spring; Summer)
  • AND my dependent variable IDE: with 3 categories

I want to do contrast for the interaction between season and land access; and a second contrast statement for the interaction between region and season:

My model (without the contrast) is:

proc logistic data = results2;

Class Land_acces (param=ref ref='Non')

region (param=ref ref='1-Sud')

season (param=ref ref='spring') / param=ref order=internal; 

model IDE_groupe(event='A - Peu ou pas de faim dans le ménage')=

season

Land_acces

region

Land_acces * season

region * season/ expb;

format season saison.;

run;

 image.png

  • Should I use this table (I got after running the code for proc logistic) to write the contrast statement?
  • What should I write in the contrast statement to have a table like this:

Region*season

Land_acces*season

 image.png

contrast 'region = 1-Sud season summer vs spring' region*season ……………… / estimate = exp ;

 contrast 'region = 2-GAE season summer vs spring' region*season ……………… / estimate = exp;

 contrast 'region = 3-GAO season summer vs spring' region*season ………………/ estimate = exp;

 

 contrast ' Land_acces = Non season summer vs spring' Land_acces*season ……………… / estimate = exp;

 contrast ' Land_acces = Wi season summer vs spring' Land_acces* season ………………/ estimate = exp;

4 REPLIES 4
PaigeMiller
Diamond | Level 26

There's no point in using a CONTRAST statement to compare one level to another level. You can use the LSMEANS statements to compare the means of interest.

 

CONTRAST statement would be useful if you want to compare some non-trivial linear combinations of the means levels; such as the average of groups 2 and 3, with the average of group 1.

--
Paige Miller
sebai
Obsidian | Level 7

proc Logistic data=results2;

         class region season terres_acces;

         model IDE_groupe = region season

terres_acces

terres_acces * season

region * season / cl ;

lsmeans region*season / oddsratio ilink cl pdiff;

lsmeans terres_acces*season / oddsratio cl pdiff;

format season saison.;

run;

I used this code and I got this table:

It doesn’t include all the levels for the 2 variables: for region, I only got 1-Sud, 2-GAE and not 3-GAO (I think it did a comparison with that level of the variable though I want it to be compared separately).

image.png

I used Lsmeans with proc glimmix and it worked very well but it was for another dependent variable with 2 categories; proc glimmix didn’t work well for me with a dependent variable with 3 categories.

   proc glimmix data=results2;

         class region

season

terres_acces;

         model MDD_W_5 = region season

terres_acces

terres_acces * season

region * season/ or dist=binary;

lsmeans region*season / slicediff=region oddsratio ilink cl pdiff;

lsmeans terres_acces*season / slicediff=terres_acces oddsratio cl pdiff;

format season saison.;

run;

This is what I got with proc Glimmix for the dependant variable with 2 categories: (I want to find results for my new dependent variable presents in a similar way!!)

image.png

PaigeMiller
Diamond | Level 26

LSMEANS is very generic, it doesn't care if the dependent variable has 2 levels or 3 levels, it will work, why don't you try it?

--
Paige Miller
Reeza
Super User

Can you use an ODDSRATIO statement instead? I find those much easier to navigate.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1297 views
  • 3 likes
  • 3 in conversation