# How do you compare OR between different groups using SAS?

How do you get a confidence interval for an odds ratio between two different groups (both of which are not the reference group) in SAS?

Suppose $x_1$ is the reference level and $x_2,x_3,x_4$ are the other variables. Odds ratios in SAS give them for each level compared to the reference (e.g. $x_2$ vs $x_1$, $x_3$ vs $x_1$ etc..). How do you get the odds ratio between $x_2$ and $x_3$ in SAS including confidence intervals?

## 2 Answers

You can do the following:

proc logistic data=thedata;
model outcome = age1 age2 age3;
estimate 'age1 vs age2' age1 1 age2 -1,
'age1 vs age3' age1 1 age3 -1,
'age2 vs age3' age2 1 age3 -1 / CL;
run;


where outcome is a binary variable, and age1, age2, and age3 are binary indicator variables.

In the output:

                             Estimates
Label          Estimate   Standard Error  z Value  Pr > |z|  Alpha  Lower   Upper
age1 vs age2   0.1122     0.1022          1.10     0.2725    0.05  -0.08819 0.3125
age1 vs age3   0.2705     0.1088          2.49     0.0129    0.05   0.05725 0.4837
age2 vs age3   0.1583     0.1094          1.45     0.1480    0.05  -0.05619 0.3728


take $exp(Estimate)$ for the OR, take $exp(Lower)$ for the lower bound of the 95% CI, and $exp(Upper)$ for the upper bound.

I assume you mean that you have a predictor variable with 4 levels, the first of which is the reference level. You can use the LSMEANS statement to get your odds ratios. Put the predictor variable in the CLASS statement and specify the reference level. The following assumes that the response, Y, has two levels 0,1 with 1 as the reference level, and the predictor, X, has 4 levels, 0,1,2,3, with 0 as the reference level. The DIFF, EXP, and CL options provide all of the odds ratios between all of the pairwise levels along with confidence intervals.

proc logistic;
class x (ref="0")/ param=ref;
model y(event="1")=x;
lsmeans x / diff exp cl;
run;