Here's code for an example dataset. proc logistic data = sashelp.heart;
class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
estimate 'Female; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 1 Smoking_Status*Sex 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Male; Heavy (16-25)' intercept 1 Smoking_Status 1 Sex 0 1 Smoking_Status*Sex 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Female; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 1 Smoking_Status*Sex 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Male; Light (1-5)' intercept 1 Smoking_Status 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Female; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Male; Moderate (6-15)' intercept 1 Smoking_Status 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Female; Very Heavy (> 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Male; Very Heavy (> 25)' intercept 1 Smoking_Status 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Female; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
estimate 'Male; Non-smoker' intercept 1 Smoking_Status 0 0 0 0 1 Sex 0 1 Smoking_Status*Sex 0 0 0 0 0 0 0 0 0 1 Cholesterol 227.4174412 Weight 153.0866808 / exp ilink e cl;
lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run; To write contrasts/estimates, I like to use the "e" option and print out the least squares means to make sure I'm writing them correctly. Categorical variables will have all levels used with GLM parameterization. In simpler cases, 1s are used for the levels of interest and 0s otherwise for estimates. For continuous variables, we can make predictions at the mean values of these variables. proc means data = sashelp.heart;
var Cholesterol Weight;
run; This is done with the "at means" option in the lsmeans statement. I don't think that your current code includes any odd ratios. You can get odds ratios from the logistic regression coefficients with the "expb" option in the model statement. The above estimate statements give you log-odds estimates and predicted probabilities (ilink option). See the calculations below for 'Female; Heavy (16-25)'. data _null_;
logOdds = -0.7022;
odds = exp(logOdds);
prob = exp(logOdds) / (exp(logOdds) + 1);
put logOdds = odds = prob = ;
run; Exponentiating the log-odds estimates will give you the odds estimates. Adding the "pdiff" and "oddsratio" options to the lsmeans statement will give differences in log-odds and odds ratios. See the calculations below for 'Female; Heavy (16-25)' vs 'Male; Heavy (16-25)'. data _null_;
logOddsDiff = -0.7022 - (-0.1660);
oddsRatio = exp(logOddsDiff);
put logOddsDiff = oddsRatio = ;
run; This modified code gives the difference in log-odds and odds ratio for 'Female; Heavy (16-25) vs Male; Heavy (16-25)' which is just subtracting the individual estimates. proc logistic data = sashelp.heart;
class Status Smoking_Status(ref = 'Non-smoker') Sex(ref = 'Male') / param = glm;
model Status(event = 'Dead') = Smoking_Status | Sex Cholesterol Weight / expb;
estimate 'Female; Heavy (16-25) vs Male; Heavy (16-25)' Sex 1 -1 Smoking_Status*Sex 1 -1 / exp ilink e cl;
lsmeans Smoking_Status * Sex / at means ilink pdiff oddsratio cl;
run; Hopefully this helps you to apply it to your own dataset. For #2, I would report the odds ratios corresponding to the interaction since it seems to be what you are interested in. For #3, look up quasi-complete separation. For #4, include the interactions justified by the theory and literature.
... View more