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:
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;
Region*season
Land_acces*season
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;
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.
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).
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!!)
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?
Can you use an ODDSRATIO statement instead? I find those much easier to navigate.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.