Resources

Example 11 for PROC LOGISTIC


/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: LOGIEX11                                            */
/*   TITLE: Example 11 for PROC LOGISTIC                        */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS: logistic regression analysis,                       */
/*          conditional logistic regression analysis,           */
/*          exact conditional logistic regression analysis,     */
/*          binomial response data,                             */
/*   PROCS: LOGISTIC                                            */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: Bob Derr                                            */
/*     REF: SAS/STAT User's Guide, PROC LOGISTIC chapter        */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/

/*****************************************************************
Example 11. Conditional Logistic Regression for Matched Pairs Data
****************************************************************/

/*
The data are a subset of data from the Los Angeles Study of the Endometrial
Cancer Data described in Breslow and Day (1980).  There are 63 matched pairs,
each consisting of a case of endometrial cancer (Outcome=1) and a control
(Outcome=0).  The case and the corresponding control have the same ID.  The
explanatory variables include Gall (an indicator for gall bladder disease)
and Hyper (an indicator for hypertension).  The goal of the analysis is to
determine the relative risk for gall bladder disease controlling for the
effect of hypertension.
*/

title 'Example 11. Conditional Logistic Regression for Matched Pairs';

data Data1;
  do ID=1 to 63;
    do Outcome = 1 to 0 by -1;
      input Gall Hyper @@;
      output;
    end;
  end;
  datalines;
0 0  0 0    0 0  0 0    0 1  0 1    0 0  1 0    1 0  0 1
0 1  0 0    1 0  0 0    1 1  0 1    0 0  0 0    0 0  0 0
1 0  0 0    0 0  0 1    1 0  0 1    1 0  1 0    1 0  0 1
0 1  0 0    0 0  1 1    0 0  1 1    0 0  0 1    0 1  0 0
0 0  1 1    0 1  0 1    0 1  0 0    0 0  0 0    0 0  0 0
0 0  0 1    1 0  0 1    0 0  0 1    1 0  0 0    0 1  0 0
0 1  0 0    0 1  0 0    0 1  0 0    0 0  0 0    1 1  1 1
0 0  0 1    0 1  0 0    0 1  0 1    0 1  0 1    0 1  0 0
0 0  0 0    0 1  1 0    0 0  0 1    0 0  0 0    1 0  0 0
0 0  0 0    1 1  0 0    0 1  0 0    0 0  0 0    0 1  0 1
0 0  0 0    0 1  0 1    0 1  0 0    0 1  0 0    1 0  0 0
0 0  0 0    1 1  1 0    0 0  0 0    0 0  0 0    1 1  0 0
1 0  1 0    0 1  0 0    1 0  0 0
;



/*
In the following SAS statements, PROC LOGISTIC is invoked with the ID
variable declared in the STRATA statement to obtain the conditional logistic
model estimates. The model contains Gall as the only predictor variable.
*/

proc logistic data=Data1;
   strata ID;
   model outcome(event='1')=Gall;
run;


/*
When you believe there is not enough data or that the data are too sparse,
you can perform a stratified exact conditional logistic regression.  The
following SAS statements perform exact conditional logistic regressions on
the original data set by specifying both the STRATA and EXACT statements.
*/

proc logistic data=Data1 exactonly;
   strata ID;
   model outcome(event='1')=Gall;
   exact Gall / estimate=both;
run;


/*
Alternatively, when each matched set consists of one event and one nonevent
you can transform each matched pair into a single observation, where the
variables Gall and Hyper contain the differences between the corresponding
values for the case and the control.  The variable Outcome, which will be
used as the response variable in the logistic regression model, is given a
constant value of 0.

PROC LOGISTIC is invoked with the NOINT option to obtain the conditional
logistic model estimates.  The model contains GALL as the only predictor
variable.  CLODDS=PL is also specified, to obtain 95\% profile-likelihood
confidence intervals for the odds ratio.
*/

data Data2;
   set Data1;
   drop id1 gall1 hyper1;
   retain id1 gall1 hyper1 0;
   if (ID = id1) then do;
      Gall=gall1-Gall; Hyper=hyper1-Hyper;
      output;
   end;
   else do;
      id1=ID; gall1=Gall; hyper1=Hyper;
   end;
run;



proc logistic data=Data2;
   model outcome=Gall / noint clodds=PL;
run;


/*
You can also perform exact conditional logistic regression on the transformed
data set.
*/

proc logistic data=Data2 exactonly;
   model outcome=Gall / noint;
   exact Gall / estimate=both;
run;