By default, PROC GENMOD does not display odds ratio estimates and PROC LOGISTIC computes odds ratio estimates only for variables not involved in interactions or nested terms. Note that when a variable is involved in an interaction there isn't a single odds ratio estimate for it. Rather, the odds ratio for the variable depends on the level(s) of the interacting variable(s).
Use the ODDSRATIO statement in PROC LOGISTIC to get odds ratio estimates of simple effects within an interaction. If you select GLM parameterization of CLASS variables in the LOGISTIC, GENMOD, GLIMMIX, or SURVEYLOGISTIC procedures then you can also use the EXP option in the LSMESTIMATE statement, or the DIFF and ODDSRATIO options in the LSMEANS and SLICE statements. The ODDSRATIO statement is the easiest way to obtain odds ratio estimates.
If you fit a logistic model using PROC GLIMMIX, you can use the ODDSRATIO option in the LSMEANS statement in conjunction with DIFF or SLICEDIFF= option to obtain odds ratio estimates. See the example below.
Custom odds ratios can be constructed using the CONTRAST or ESTIMATE statements in PROC LOGISTIC or the ESTIMATE statement in the GENMOD or GLIMMIX procedure. These statements are the most general and flexible for estimating odds ratios and can be used when a continuous predictor is involved or when a parameterization other than GLM parameterization is used for CLASS variables. However, the generality of these statements make them the most difficult to use. Fortunately, most needs can be satisfied by one of the statements discussed above. While assistance with constructing custom odds ratios is beyond the scope of the services provided by Technical Support, this note illustrates the proper method for determining how to construct CONTRAST and ESTIMATE statements. See the Introduction and Example 3 which uses a logistic model with interaction and shows construction of a custom odds ratio using either of two coding methods for categorical predictors.
The example below and Example 3 of this note illustrate use of the ODDSRATIO, LSMEANS, LSMESTIMATE, SLICE, ESTIMATE, and CONTRAST statements to compute an odds ratio of interest. This note uses the LSMEANS, LSMESTIMATE, and ESTIMATE statements to estimate odds ratios in a model without interaction in PROC GENMOD. For details and additional options, see the descriptions of the above statements and options in the documentation for the LOGISTIC, GENMOD, or GLIMMIX procedures.
In the following example, patients with one of two diagnoses (complicated or uncomplicated) are treated with one of three treatments (A, B, or C) and the result (cured or not cured) is observed.
data uti; input diagnosis : $13. treatment $ response $ count @@; datalines; complicated A cured 78 complicated A not 28 complicated B cured 101 complicated B not 11 complicated C cured 68 complicated C not 46 uncomplicated A cured 40 uncomplicated A not 5 uncomplicated B cured 54 uncomplicated B not 5 uncomplicated C cured 34 uncomplicated C not 6 ;
The following PROC LOGISTIC step uses all six of the statements mentioned above to estimate the odds ratio comparing the A and C treatments in the complicated diagnosis. Any one of the statements alone would suffice. Some of these statements produce additional odds ratio estimates for comparing other treatment pairs. The ODDSRATIO and CONTRAST statements provide confidence limits by default. Confidence limits are available in the other statements by adding an option (typically, CL). When ODS Graphics is enabled, plots of odds ratios or of log odds differences are also provided.
proc logistic data=uti; freq count; class diagnosis treatment / param=glm; model response(event="cured") = diagnosis treatment diagnosis*treatment; oddsratio treatment / at(diagnosis='complicated'); lsmeans diagnosis*treatment / ilink oddsratio diff; slice diagnosis*treatment / sliceby(diagnosis='complicated') diff oddsratio; lsmestimate diagnosis*treatment 'A vs C complicated' 1 0 1 / exp; estimate 'A vs C in complicated' treatment 1 0 1 diagnosis*treatment 1 0 1 0 0 0 / exp; contrast 'A vs C in complicated' treatment 1 0 1 diagnosis*treatment 1 0 1 0 0 0 / estimate=exp; run;
These results are created by the ODDSRATIO statement. The AT option is used to limit the results to the complicated diagnosis. The odds ratio comparing treatments A and C in the complicated diagnosis is estimated to be 1.88. A 95% confidence interval for the odds ratio is (1.064, 3.337). If pvalues are desired, specify the ORPVALUE option in the MODEL statement as discussed in this note.

The next results are created by the LSMEANS statement. Shown first is the table of LSmeans which contains estimates of the log odds (Estimate column), the odds ratio, and the probability of being cured (Mean column) for each treatment and diagnosis combination. The ODDSRATIO option produces the Odds Ratio columns in the Differences table. The ILINK option produces the Mean (probability) column. Note that the estimated odds of being cured by treatment A in the complicated diagnosis are 2.79 and the estimated probability of being cured is 0.74. The table of LSmean differences which follows contains estimates of the log odds ratio (Estimate column) and the odds ratio (provided by the ODDSRATIO option). This table is produced by the DIFF option. The odds ratio estimate for A vs C in the complicated diagnosis is again found to be 1.88.

The following is produced by the SLICE statement. The SLICEBY option requests comparisons of treatments within the complicated diagnosis. The first table provides a joint test of the treatment differences in the complicated diagnosis. The DIFF option produces the next table containing log odds ratio (Estimate column) and odds ratio estimates (produced by the ODDSRATIO option). The odds ratio estimate for A vs C in the complicated diagnosis is again 1.88.

The LSMESTIMATE statement provides the next table. The LSMESTIMATE statement allows you to specify custom contrasts of the LSmeans. Since A and C in the complicated diagnosis are the first and third LSmeans as shown in the "diagnosis*treatment Least Squares Means" table from the LSMEANS statement, the specified coefficients (1 0 1) estimate the difference in log odds (logs odds ratio) between treatments A and C in the complicated diagnosis (0.63). The EXP option adds the Exponentiated column containing the odds ratio estimate (again, 1.88).

The following results come from the ESTIMATE statement. See Example 3 in this note for how the coefficients are determined. The results show the log odds ratio estimate (0.63) and the EXP option provides the odds ratio estimate (1.88).

The CONTRAST statement produces these results. The coefficients are determined in the same way as for the ESTIMATE statement. An overall test of the specified contrast is provided first. The ESTIMATE=EXP option produces the estimated odds ratio (1.88). A test and confidence limits are also provided.
The following statements produce odds ratio estimates and confidence limits for comparing two treatments at each level of the interacting diagnosis variable using PROC GLIMMIX:
proc glimmix data=uti; freq count; class diagnosis treatment; model response = diagnosis treatment diagnosis*treatment / dist=binary; lsmeans diagnosis*treatment / slicediff=diagnosis oddsratio ilink; run;
Following are the results from the LSMEANS statement which are very similar to the LSMEANS results from PROC LOGISTIC above. The first table provides estimates of the log odds (Estimate column) and probability (Mean column) of being cured. The ILINK option produces the mean (probability) estimates. The second table provides estimates of the log odds ratio (Estimate column) and odds ratio for each comparison of treatments. The ODDSRATIO option produces the odds ratio estimates.

Product Family  Product  System  SAS Release  
Reported  Fixed*  
SAS System  SAS/STAT  All  n/a 
Type:  Usage Note 
Priority:  low 
Topic:  SAS Reference ==> Procedures ==> GENMOD SAS Reference ==> Procedures ==> LOGISTIC SAS Reference ==> Procedures ==> GLIMMIX Analytics ==> Categorical Data Analysis SAS Reference ==> Procedures ==> SURVEYLOGISTIC 
Date Modified:  20170714 10:41:13 
Date Created:  20051109 11:39:58 