FOCUS AREAS

Categorical Data Analysis: Chapter 15

  

   options nodate nonumber ps=200 ls=80;

   data children;
      input id city$ @@;
      do i=1 to 4;
         input age smoke symptom @@;
         output;
      end;
      datalines;
    1 steelcity  8 0 1  9 0 1  10 0 1  11 0 0  
    2 steelcity  8 2 1  9 2 1  10 2 1  11 1 0
    3 steelcity  8 2 1  9 2 0  10 1 0  11 0 0
    4 greenhills 8 0 0  9 1 1  10 1 1  11 0 0
    5 steelcity  8 0 0  9 1 0  10 1 0  11 1 0
    6 greenhills 8 0 1  9 0 0  10 0 0  11 0 1
    7 steelcity  8 1 1  9 1 1  10 0 1  11 0 0
    8 greenhills 8 1 0  9 1 0  10 1 0  11 2 0
    9 greenhills 8 2 1  9 2 0  10 1 1  11 1 0
   10 steelcity  8 0 0  9 0 0  10 0 0  11 1 0
   11 steelcity  8 1 1  9 0 0  10 0 0  11 0 1
   12 greenhills 8 0 0  9 0 0  10 0 0  11 0 0
   13 steelcity  8 2 1  9 2 1  10 1 0  11 0 1
   14 greenhills 8 0 1  9 0 1  10 0 0  11 0 0
   15 steelcity  8 2 0  9 0 0  10 0 0  11 2 1
   16 greenhills 8 1 0  9 1 0  10 0 0  11 1 0
   17 greenhills 8 0 0  9 0 1  10 0 1  11 1 1  
   18 steelcity  8 1 1  9 2 1  10 0 0  11 1 0
   19 steelcity  8 2 1  9 1 0  10 0 1  11 0 0
   20 greenhills 8 0 0  9 0 1  10 0 1  11 0 0
   21 steelcity  8 1 0  9 1 0  10 1 0  11 2 1
   22 greenhills 8 0 1  9 0 1  10 0 0  11 0 0
   23 steelcity  8 1 1  9 1 0  10 0 1  11 0 0
   24 greenhills 8 1 0  9 1 1  10 1 1  11 2 1
   25 greenhills 8 0 1  9 0 0  10 0 0  11 0 0
   ;  

   proc genmod data=children descending;
      class id city;
      model symptom = city age smoke  / 
                      link=logit dist=bin type3;
      repeated subject=id / type=exch covb corrw;
   run;

   ods select Estimates;  
   proc genmod data=children descending;
      class id city;
      model symptom = city age smoke  / 
                      link=logit dist=bin type3;
      repeated subject=id / type=exch covb corrw;
      estimate 'smoking' smoke 1 / exp;  
   run; 

   data cross (drop=count);
      input age $ sequence $ time1 $ time2 $ count;
      do i=1 to count;
         output;
      end;
      datalines;
   older AB F F 12 
   older AB F U 12 
   older AB U F 6 
   older AB U U 20 
   older BP F F 8
   older BP F U 5
   older BP U F 6 
   older BP U U 31
   older PA F F 5
   older PA F U 3
   older PA U F 22
   older PA U U 20
   younger BA F F 19 
   younger BA F U 3 
   younger BA U F  25
   younger BA U U  3
   younger AP F F 25 
   younger AP F U 6
   younger AP U F 6
   younger AP U U 13
   younger PB F F 13
   younger PB F U 5
   younger PB U F 21 
   younger PB U U 11
   ;

   data cross2; 
      set cross;
      subject=_n_;
         period=1;
            drug = substr(sequence, 1, 1);
            carry='N';
            response = time1;
            output;
         period=0;
            drug  = substr(sequence, 2, 1);
            carry = substr(sequence, 1, 1);
            if carry='P' then carry='N'; 
            response = time2;
            output;
   run;
   proc print data=cross2(obs=15);
   run;     

   proc genmod data=cross2;
      class subject age drug carry;
      model response = period age drug
                       period*age carry
                       drug*age / dist=bin type3;
      repeated subject=subject/type=unstr;
   run;

   ods select Contrasts;    
   proc genmod data=cross2;
      class subject age drug carry;
      model response = period age drug
                       period*age carry
                       drug*age / dist=bin type3;
      repeated subject=subject/type=unstr;
      contrast 'carry' carry 1 0 -1, 
                       carry 0 1 -1; 
      contrast 'inter' age*drug 1 0 -1 -1 0  1 ,
                       age*drug 0 1 -1  0 -1 1 ;   
      contrast 'joint' carry 1 0 -1, 
                       carry 0 1 -1, 
                       age*drug 1 0 -1 -1 0  1 ,
                       age*drug 0 1 -1  0 -1 1 ;   
   run;

   ods select GEEEmpPEst Type3 GEEWCorr;
   proc genmod data=cross2;
      class subject age drug;
      model response = period age drug
                       period*age
         / dist=bin type3;
      repeated subject=subject/type=unstr corrw; 
   run;

   ods select Contrasts;
   proc genmod data=cross2;
      class subject age drug;
      model response = period age drug
                       period*age
                     / dist=bin type3;
      repeated subject=subject/type=unstr;
      contrast 'A versus B' drug 1 -1 0; 
   run; 

   data resp;
      input center id treatment $ sex $ age baseline 
      visit1-visit4 @@;
      visit=1;  outcome=visit1;  output;   
      visit=2;  outcome=visit2;  output;   
      visit=3;  outcome=visit3;  output;   
      visit=4;  outcome=visit4;  output;   
      datalines;
   1  53 A F  32 1  2 2 4 2  2  30 A F  37 1  3 4 4 4  
   1  18 A F  47 2  2 3 4 4  2  52 A F  39 2  3 4 4 4  
   1  54 A M  11 4  4 4 4 2  2  23 A F  60 4  4 3 3 4  
   1  12 A M  14 2  3 3 3 2  2  54 A F  63 4  4 4 4 4  
   1  51 A M  15 0  2 3 3 3  2  12 A M  13 4  4 4 4 4  
   1  20 A M  20 3  3 2 3 1  2  10 A M  14 1  4 4 4 4  
   1  16 A M  22 1  2 2 2 3  2  27 A M  19 3  3 2 3 3  
   1  50 A M  22 2  1 3 4 4  2  16 A M  20 2  4 4 4 3  
   1   3 A M  23 3  3 4 4 3  2  47 A M  20 2  1 1 0 0  
   1  32 A M  23 2  3 4 4 4  2  29 A M  21 3  3 4 4 4  
   1  56 A M  25 2  3 3 2 3  2  20 A M  24 4  4 4 4 4  
   1  35 A M  26 1  2 2 3 2  2   2 A M  25 3  4 3 3 1  
   1  26 A M  26 2  2 2 2 2  2  15 A M  25 3  4 4 3 3  
   1  21 A M  26 2  4 1 4 2  2  25 A M  25 2  2 4 4 4  
   1   8 A M  28 1  2 2 1 2  2   9 A M  26 2  3 4 4 4  
   1  30 A M  28 0  0 1 2 1  2  49 A M  28 2  3 2 2 1  
   1  33 A M  30 3  3 4 4 2  2  55 A M  31 4  4 4 4 4  
   1  11 A M  30 3  4 4 4 3  2  43 A M  34 2  4 4 2 4  
   1  42 A M  31 1  2 3 1 1  2  26 A M  35 4  4 4 4 4  
   1   9 A M  31 3  3 4 4 4  2  14 A M  37 4  3 2 2 4  
   1  37 A M  31 0  2 3 2 1  2  36 A M  41 3  4 4 3 4  
   1  23 A M  32 3  4 4 3 3  2  51 A M  43 3  3 4 4 2  
   1   6 A M  34 1  1 2 1 1  2  37 A M  52 1  2 1 2 2  
   1  22 A M  46 4  3 4 3 4  2  19 A M  55 4  4 4 4 4  
   1  24 A M  48 2  3 2 0 2  2  32 A M  55 2  2 3 3 1  
   1  38 A M  50 2  2 2 2 2  2   3 A M  58 4  4 4 4 4  
   1  48 A M  57 3  3 4 3 4  2  53 A M  68 2  3 3 3 4  
   1   5 P F  13 4  4 4 4 4  2  28 P F  31 3  4 4 4 4  
   1  19 P F  31 2  1 0 2 2  2   5 P F  32 3  2 2 3 4  
   1  25 P F  35 1  0 0 0 0  2  21 P F  36 3  3 2 1 3  
   1  28 P F  36 2  3 3 2 2  2  50 P F  38 1  2 0 0 0  
   1  36 P F  45 2  2 2 2 1  2   1 P F  39 1  2 1 1 2  
   1  43 P M  13 3  4 4 4 4  2  48 P F  39 3  2 3 0 0  
   1  41 P M  14 2  2 1 2 3  2   7 P F  44 3  4 4 4 4  
   1  34 P M  15 2  2 3 3 2  2  38 P F  47 2  3 3 2 3  
   1  29 P M  19 2  3 3 0 0  2   8 P F  48 2  2 1 0 0  
   1  15 P M  20 4  4 4 4 4  2  11 P F  48 2  2 2 2 2  
   1  13 P M  23 3  3 1 1 1  2   4 P F  51 3  4 2 4 4  
   1  27 P M  23 4  4 2 4 4  2  17 P F  58 1  4 2 2 0  
   1  55 P M  24 3  4 4 4 3  2  39 P M  11 3  4 4 4 4  
   1  17 P M  25 1  1 2 2 2  2  40 P M  14 2  1 2 3 2  
   1  45 P M  26 2  4 2 4 3  2  24 P M  15 3  2 2 3 3  
   1  40 P M  26 1  2 1 2 2  2  41 P M  15 4  3 3 3 4  
   1  44 P M  27 1  2 2 1 2  2  33 P M  19 4  2 2 3 3  
   1  49 P M  27 3  3 4 3 3  2  13 P M  20 1  4 4 4 4  
   1  39 P M  28 2  1 1 1 1  2  34 P M  20 3  2 4 4 4  
   1   2 P M  28 2  0 0 0 0  2  45 P M  33 3  3 3 2 3  
   1  14 P M  30 1  0 0 0 0  2  22 P M  36 2  4 3 3 4  
   1  10 P M  37 3  2 3 3 2  2  18 P M  38 4  3 0 0 0  
   1  31 P M  37 1  0 0 0 0  2  35 P M  42 3  2 2 2 2  
   1   7 P M  43 2  3 2 4 4  2  44 P M  43 2  1 0 0 0  
   1  52 P M  43 1  1 1 3 2  2   6 P M  45 3  4 2 1 2  
   1   4 P M  44 3  4 3 4 2  2  46 P M  48 4  4 0 0 0  
   1   1 P M  46 2  2 2 2 2  2  31 P M  52 2  3 4 3 4   
   1  46 P M  49 2  2 2 2 2  2  42 P M  66 3  3 3 4 4   
   1  47 P M  63 2  2 2 2 2  
   ;
   data resp2; set resp; 
      dichot=(outcome=3 or outcome=4); 
      di_base = (baseline=3 or baseline=4); 
   run; 

   proc genmod descending;
      class id center treatment visit;
      model dichot = center treatment visit /
                     link=logit dist=bin type3;
      repeated subject=id*center / type=unstr;
   run; 

   proc genmod descending;
      class id center sex treatment visit;
      model dichot = treatment sex age center di_base
                     visit visit*treatment treatment*center/
                     link=logit dist=bin type3;
      repeated subject=id*center / type=exch;
   run; 

   proc genmod descending;
      class id center sex treatment visit;
      model dichot = center sex treatment age di_base
                     visit / link=logit dist=bin type3;
      repeated subject=id*center / type=exch;
   run; 

   proc genmod descending;
      class id center sex treatment visit;
      model dichot = center sex treatment age di_base
                     / link=logit dist=bin type3;
      repeated subject=id*center / type=exch corrw;
   run; 

   proc genmod descending;
      class id center sex treatment visit;
      model dichot = center sex treatment age di_base
                     / link=logit dist=bin type3;
      repeated subject=id*center / type=unstr corrw;
   run; 

   proc genmod descending;
      class id center sex treatment visit;
      model dichot = center sex treatment age di_base
                     / link=logit dist=bin type3;
      repeated subject=id*center / type=ind corrw;
   run; 

   %macro geef;
   data temp1;
      set clustout;
      drop Label1 cvalue1; 
      if Label1='Number of Clusters';
   run;
   data temp2;
      set scoreout;
      drop ProbChiSq;
   run;
   data temp3;
      merge temp1 temp2;
   run; 
   data temp4; set temp3;
     retain nclusters; drop nvalue1;
     if _n_=1 then nclusters=nvalue1;
   run; 
   data temp5; 
      set temp4;
      drop ChiSq nclusters d; 
      d=nclusters-1;
      NewF= ((d-df+1)*ChiSq)/(d*df);
      ProbF=1-cdf('F', NewF,df,d-df+1); 
   run;
 
/* Set the ODS path to include your store first (this 
   sets the search path order so that ODS looks in your
   store first, followed by the default store */

ods path sasuser.templat (update)
         sashelp.tmplmst (read);

/* Print the path to the log to make sure you will get 
   what you expect */

*ods path show;

/* Define your table, and store it */
   proc template;
      define table GEEType3F;
      parent=Stat.Genmod.Type3GEESc;
      header "#F-Statistics for Type 3 GEE Analysis##";
      column Source DF i NewF ProbF;
      define NewF;
      parent = Common.ANOVA.FValue;
    end;
   end;
   run;
   title1;
   data _null_;
      set temp5;
      file print ods=(template='GEEType3F');
      put _ods_;
   run;
;
%mend geef;

   ods output GEEModInfo=clustout 
               Type3=scoreout;
   proc genmod descending data=resp2;
      class id center sex treatment visit;
      model dichot = treatment sex center age di_base
                    visit / link=logit dist=bin type3 wald;
      repeated subject=id*center / type=exch;
   run; 
   %geef;

   data diagnos;
      input std1 $ test1 $ std2 $ test2 $ count;
      do i=1 to count; 
       output;
      end;
      datalines;
   Neg Neg Neg Neg 509
   Neg Neg Neg Pos   4
   Neg Neg Pos Neg  17
   Neg Neg Pos Pos   3
   Neg Pos Neg Neg  13
   Neg Pos Neg Pos   8
   Neg Pos Pos Neg   0
   Neg Pos Pos Pos   8
   Pos Neg Neg Neg  14
   Pos Neg Neg Pos   1
   Pos Neg Pos Neg  17
   Pos Neg Pos Pos   9
   Pos Pos Neg Neg   7
   Pos Pos Neg Pos   4
   Pos Pos Pos Neg   9
   Pos Pos Pos Pos 170
   ;
   data diagnos2;
      set diagnos; 
       drop std1 test1 std2 test2;
      subject=_n_;
      time=1; procedure='standard';
      response=std1; output; 
       time=1; procedure='test';
      response=test1; output;
      time=2; procedure='standard';
       response=std2; output; 
       time=2; procedure='test';
      response=test2; output;
   run;

   proc genmod descending; 
      class subject time procedure; 
      model response = time procedure time*procedure /
                       link=logit dist=bin type3;
      repeated subject=subject /type=exch; 
   run; 

   proc genmod descending; 
      class subject time procedure; 
      model response = time procedure /
                       link=logit dist=bin type3;
      repeated subject=subject / type=exch corrw; 
   run; 

   proc genmod descending; 
      class subject time procedure; 
      model response = time procedure /
                       link=logit dist=bin;
      repeated subject=subject /type=unstr corrw; 
   run; 


   data fracture; 
      input ID age center $ treatment $ year1 year2 year3 @@;
      total=year1+year2+year3;
      lmonths=log(12); 
      datalines;  
   1  56 A p 0 0 0   2 71 A p 1 0 0   3 60 A p 0 0 1   4 71 A p 0 1 0 
   5  78 A p 0 0 0   6 67 A p 0 0 0   7 49 A p 0 0 0    
   9  75 A p 1 0 0   8 68 A p 0 0 0  11 82 A p 0 0 0   
  13  56 A p 0 0 0  12 71 A p 0 0 0  15 66 A p 1 0 0  
  17  78 A p 0 0 0  16 63 A p 0 2 0  19 61 A p 0 0 0   
  21  75 A p 1 0 0  20 68 A p 0 0 0  23 63 A p 1 1 1   
  25  54 A p 0 0 0  24 65 A p 0 0 0  27 71 A p 0 0 0   
  29  56 A p 0 0 0  28 64 A p 0 0 0  31 78 A p 0 0 2   
  33  76 A p 0 0 0  32 61 A p 0 0 0  35 76 A p 0 0 0   
  37  74 A p 0 0 0  36 56 A p 0 0 0  39 62 A p 0 0 0   
  41  56 A p 0 0 0  40 72 A p 0 0 1  43 76 A p 0 0 0   
  45  75 A p 0 0 0  44 77 A p 2 2 0  47 78 A p 0 0 0   
  49  71 A p 0 0 0  48 68 A p 0 0 0  51 74 A p 0 0 0   
  53  69 A p 0 0 0  52 78 A p 1 0 0  55 81 A p 2 0 1   
  57  68 A p 0 0 0  56 77 A p 0 0 0  59 77 A p 0 0 0   
  61  75 A p 0 0 0  60 83 A p 0 0 0  63 72 A p 0 0 0  64 88 A p 0 0 0 
  65  69 A p 0 0 0  66 55 A p 0 0 0  67 76 A p 0 0 0  68 55 A p 0 0 0 
  69  63 A t 0 0 2  70 52 A t 0 0 0  71 56 A t 0 0 0  72 52 A t 0 0 0 
  73  74 A t 0 0 0  74 61 A t 0 0 0  75 69 A t 0 0 0  76 61 A t 0 0 0 
  77  84 A t 0 0 0  78 76 A t 0 1 0  79 59 A t 0 0 1  80 76 A t 0 0 0 
  81  66 A t 0 0 1  82 78 A t 0 0 1  83 77 A t 0 0 0  84 75 A t 1 0 0 
  85  75 A t 0 0 0  86 62 A t 0 0 0  87 67 A t 0 0 0  88 62 A t 0 0 0 
  89  71 A t 0 0 0  90 63 A t 0 0 0                   92 68 A t 0 0 0 
  93  69 A t 0 0 0  94 61 A t 0 0 0                   96 61 A t 0 0 0 
  97  67 A t 0 0 0  98 77 A t 0 0 0 91  70 A t 0 0 1 102 81 A t 0 0 0                   
  95  49 A t 0 0 0 106 55 A t 0 0 0                   
  99  63 A t 2 1 0 100 52 A t 0 0 0 101 48 A t 0 0 0  
  103 71 A t 0 0 0 104 61 A t 0 0 0 105 74 A t 0 0 0  
  107 67 A t 0 0 0 108 56 A t 0 0 0 109 54 A t 0 0 0  
  111 56 A t 0 0 0 112 77 A t 1 0 0 113 65 A t 0 0 0  
  115 66 A t 0 0 0 116 71 A t 0 0 0 117 71 A t 0 0 0 128 71 A t 0 0 0 
  119 86 A t 1 0 0 120 81 A t 0 0 0 121 64 A t 0 0 0 132 76 A t 0 0 0 
  123 71 A t 0 0 0 124 76 A t 0 0 0 125 66 A t 0 0 0 136 76 A t 0 0 0 
  1  68 B p 0 0 0   2 63 B p 0 0 0  3  66 B p 0 0 0   4 63 B p 0 0 0 
  5  70 B p 0 1 0   6 62 B p 0 0 0  7  54 B p 1 0 0   8 66 B p 0 0 0 
  9  71 B p 0 0 0  10 76 B p 0 0 0 11  72 B p 0 0 1  12 65 B p 0 1 0 
  13 55 B p 0 1 0  14 59 B p 0 0 2 15  61 B p 1 0 0  16 56 B p 0 1 0   
  17  54 B p 0 0 0  18 68 B p 0 0 0 19  68 B p 0 0 0  20 81 B p 0 0 0 
  21  81 B p 1 0 0  22 61 B p 2 0 1 23  72 B p 1 0 0  24 67 B p 0 0 0 
  25  56 B p 0 0 0  26 66 B p 0 0 0 27  71 B p 0 1 0  28 75 B p 0 1 0 
  29  76 B p 0 0 0  30 73 B p 2 0 0 31  56 B p 0 0 0  32 89 B p 0 0 0 
  33  56 B p 0 0 0  34 78 B p 0 0 0 35  55 B p 0 0 0  36 73 B p 0 0 1 
  37  71 B p 0 0 0  38 56 B p 0 0 0 39  69 B p 0 0 0  40 77 B p 0 0 0 
  41  89 B p 0 0 0  42 63 B p 0 0 0 43  67 B p 0 0 0  44 73 B p 0 0 0 
  45  60 B p 0 0 0  46 67 B p 0 0 0 47  56 B p 0 0 0  48 78 B p 0 0 0 
  49  73 B t 1 0 0  50 76 B t 0 0 0 51  61 B t 0 0 0  52 81 B t 0 0 0 
  53  55 B t 0 0 0  54 82 B t 0 0 0 55  78 B t 0 0 0  56 60 B t 0 0 0 
  57  56 B t 0 0 0  58 83 B t 0 0 0 59  55 B t 0 0 0  60 60 B t 0 0 0 
  61  80 B t 0 0 0  62 78 B t 0 0 0 63  67 B t 0 0 0  64 67 B t 0 0 0 
  65  56 B t 0 0 0  66 72 B t 0 0 0 67  71 B t 0 0 0  68 83 B t 0 0 0 
  69  66 B t 0 0 0  70 71 B t 0 0 1 71  78 B t 1 0 2  72 61 B t 0 0 0 
  73  56 B t 0 0 0  74 61 B t 0 0 0 75  55 B t 0 0 0  76 69 B t 1 1 0 
  77  71 B t 0 0 0  78 76 B t 0 0 0 79  56 B t 0 0 0  80 75 B t 0 0 0 
  81  89 B t 0 0 0  82 77 B t 0 0 0 83  77 B t 1 0 0  84 73 B t 0 0 0 
  85  60 B t 0 0 0  86 61 B t 0 0 0 87  79 B t 0 0 0  88 71 B t 0 0 0 
  89  61 B t 0 0 0  90 79 B t 0 0 0 91  87 B t 1 0 0  92 55 B t 0 0 0 
  93  55 B t 0 0 0  94 79 B t 0 0 0 95  66 B t 0 0 0  96 49 B t 0 0 0 
  97  56 B t 0 0 0  98 64 B t 0 0 0 99  88 B t 0 0 0 100 62 B t 1 0 0 
  101 80 B t 0 0 1 102 65 B t 0 0 0 103 57 B t 0 0 1 104 85 B t 0 0 0
  ;

   data fracture2; 
      set fracture; 
      drop year1-year3;
      year=1; fractures=year1; output; 
      year=2; fractures=year2; output; 
      do; if center = A then do; 
        if (ID=85 or ID=66 or ID=124 or ID=51) then lmonths=log(6); end;
        if center = B then do; 
        if (ID=29 or ID=45 or ID=55) then lmonths=log(6); end;
      end; 
      year=3; fractures=year3; output; 
   run;

   proc genmod; 
      class id treatment center year;
      model fractures = center treatment age year treatment*center
                        treatment*year/ 
                        dist=poisson type3 offset=lmonths;
      repeated subject=id*center / type=exch corrw; 
   run;

   proc genmod; 
      class id treatment center year;
      model fractures = center treatment age year / 
                        dist=poisson type3 offset=lmonths;
     repeated subject=id(center) / type=exch corrw; 
   run;

   proc genmod data=resp2 descending;
      class id center sex treatment visit;
      model outcome = treatment sex center age baseline
                      visit visit*treatment /
                      link=clogit dist=mult type3;
      repeated subject=id*center / type=ind;
   run; 

   proc genmod data=resp2 descending;
      class id center sex treatment visit;
      model outcome = treatment center baseline
                      visit visit*treatment /
                      link=clogit dist=mult type3;
      repeated subject=id*center / type=ind;
   run; 

   data skincross;
      input subject gender $ sequence $ Time1 $ Time2 $ @@;         
      datalines;                 
    1  m AB   Y   Y  101 m   PA  Y   Y    201 f  AP    Y   Y 
    2  m AB   Y   .  102 m   PA  Y   Y    202 f  AP    Y   Y  
    3  m AB   Y   Y  103 m   PA  Y   Y    203 f  AP    Y   Y  
    4  m AB   Y   .  104 m   PA  Y   Y    204 f  AP    Y   Y  
    5  m AB   Y   Y  105 m   PA  Y   Y    205 f  AP    Y   Y  
    6  m AB   Y   .  106 m   PA  Y   N    206 f  AP    Y   Y  
    7  m AB   Y   .  107 m   PA  Y   .    207 f  AP    Y   Y  
    8  m AB   Y   Y  108 m   PA  Y   N    208 f  AP    Y   Y  
    9  m AB   Y   Y  109 m   PA  N   .    209 f  AP    Y   Y  
   10  m AB   Y   Y  110 m   PA  N   Y    210 f  AP    Y   Y  
   11  m AB   Y   .  111 m   PA  N   Y    211 f  AP    Y   Y  
   12  m AB   Y   Y  112 m   PA  N   Y    212 f  AP    Y   Y  
   13  m AB   Y   N  113 m   PA  N   .    213 f  AP    Y   Y  
   14  m AB   Y   N  114 m   PA  N   .    214 f  AP    Y   .  
   15  m AB   Y   N  115 m   PA  N   Y    215 f  AP    Y   .  
   16  m AB   Y   N  116 m   PA  N   Y    216 f  AP    Y   .  
   17  m AB   Y   N  117 m   PA  N   Y    217 f  AP    Y   Y  
   18  m AB   Y   N  118 m   PA  N   Y    218 f  AP    Y   Y  
   19  m AB   Y   .  119 m   PA  N   Y    219 f  AP    Y   Y  
   20  m AB   Y   N  120 m   PA  N   Y    220 f  AP    Y   Y  
   21  m AB   Y   N  121 m   PA  N   Y    221 f  AP    Y   .  
   22  m AB   Y   N  122 m   PA  N   Y    222 f  AP    Y   Y  
   23  m AB   Y   .  123 m   PA  N   Y    223 f  AP    Y   Y  
   24  m AB   Y   N  124 m   PA  N   Y    224 f  AP    Y   Y  
   25  m AB   N   Y  125 m   PA  N   Y    225 f  AP    Y   Y  
   26  m AB   N   .  126 m   PA  N   Y    226 f  AP    Y   N  
   27  m AB   N   .  127 m   PA  N   Y    227 f  AP    Y   N  
   28  m AB   N   .  128 m   PA  N   Y    228 f  AP    Y   N  
   29  m AB   N   Y  129 m   PA  N   Y    229 f  AP    Y   .  
   30  m AB   N   Y  130 m   PA  N   Y    230 f  AP    Y   N  
   31  m AB   N   .  131 m   PA  N   .    231 f  AP    Y   N  
   32  m AB   N   N  132 m   PA  N   N    232 f  AP    N   Y  
   33  m AB   N   N  133 m   PA  N   N    233 f  AP    N   Y  
   34  m AB   N   N  134 m   PA  N   N    234 f  AP    N   Y  
   35  m AB   N   N  135 m   PA  N   N    235 f  AP    N   Y  
   36  m AB   N   N  136 m   PA  N   .    236 f  AP    N   Y  
   37  m AB   N   N  137 m   PA  N   N    237 f  AP    N   Y  
   38  m AB   N   N  138 m   PA  N   N    238 f  AP    N   N  
   39  m AB   N   N  139 m   PA  N   .    239 f  AP    N   N  
   40  m AB   N   N  140 m   PA  N   N    240 f  AP    N   N  
   41  m AB   N   .  141 m   PA  N   N    241 f  AP    N   N  
   42  m AB   N   N  142 m   PA  N   N    242 f  AP    N   N  
   43  m AB   N   N  143 m   PA  N   N    243 f  AP    N   N  
   44  m AB   N   N  144 m   PA  N   N    244 f  AP    N   N  
   45  m AB   N   .  145 m   PA  N   N    245 f  AP    N   N  
   46  m AB   N   N  146 m   PA  N   N    246 f  AP    N   N  
   47  m AB   N   N  147 m   PA  N   N    247 f  AP    N   N  
   48  m AB   N   N  148 m   PA  N   N    248 f  AP    N   N  
   49  m AB   N   N  149 m   PA  N   N    249 f  AP    N   N  
   50  m AB   N   N  150 m   PA  N   .    250 f  AP    N   N  
   51  m BP   Y   Y  151 f   BA  Y   Y    251 f  PB    Y   .  
   52  m BP   Y   Y  152 f   BA  Y   Y    252 f  PB    Y   Y  
   53  m BP   Y   Y  153 f   BA  Y   Y    253 f  PB    Y   Y  
   54  m BP   Y   Y  154 f   BA  Y   .    254 f  PB    Y   Y  
   55  m BP   Y   Y  155 f   BA  Y   Y    255 f  PB    Y   Y  
   56  m BP   Y   Y  156 f   BA  Y   Y    256 f  PB    Y   .  
   57  m BP   Y   Y  157 f   BA  Y   Y    257 f  PB    Y   Y 
   58  m BP   Y   Y  158 f   BA  Y   Y    258 f  PB    Y   .  
   59  m BP   Y   N  159 f   BA  Y   Y    259 f  PB    Y   Y  
   60  m BP   Y   .  160 f   BA  Y   Y    260 f  PB    Y   Y  
   61  m BP   Y   N  161 f   BA  Y   .    261 f  PB    Y   Y  
   62  m BP   Y   .  162 f   BA  Y   .    262 f  PB    Y   .  
   63  m BP   Y   N  163 f   BA  Y   Y    263 f  PB    Y   .  
   64  m BP   N   Y  164 f   BA  Y   Y    264 f  PB    Y   N  
   65  m BP   N   Y  165 f   BA  Y   Y    265 f  PB    Y   N  
   66  m BP   N   Y  166 f   BA  Y   Y    266 f  PB    Y   N  
   67  m BP   N   Y  167 f   BA  Y   Y    267 f  PB    Y   N  
   68  m BP   N   Y  168 f   BA  Y   Y    268 f  PB    Y   N  
   69  m BP   N   Y  169 f   BA  Y   Y    269 f  PB    N   Y  
   70  m BP   N   .  170 f   BA  Y   .    270 f  PB    N   Y  
   71  m BP   N   N  171 f   BA  Y   N    271 f  PB    N   Y  
   72  m BP   N   N  172 f   BA  Y   N    272 f  PB    N   .  
   73  m BP   N   N  173 f   BA  N   Y    273 f  PB    N   .  
   74  m BP   N   N  174 f   BA  N   Y    274 f  PB    N   Y  
   75  m BP   N   N  175 f   BA  N   .    275 f  PB    N   Y  
   76  m BP   N   N  176 f   BA  N   Y    276 f  PB    N   Y  
   77  m BP   N   N  177 f   BA  N   Y    277 f  PB    N   .  
   78  m BP   N   N  178 f   BA  N   Y    278 f  PB    N   Y  
   79  m BP   N   N  179 f   BA  N   .    279 f  PB    N   Y  
   80  m BP   N   N  180 f   BA  N   .    280 f  PB    N   Y  
   81  m BP   N   .  181 f   BA  N   Y    281 f  PB    N   Y  
   82  m BP   N   N  182 f   BA  N   Y    282 f  PB    N   Y  
   83  m BP   N   .  183 f   BA  N   Y    283 f  PB    N   Y  
   84  m BP   N   N  184 f   BA  N   Y    284 f  PB    N   Y  
   85  m BP   N   .  185 f   BA  N   Y    285 f  PB    N   Y  
   86  m BP   N   N  186 f   BA  N   Y    286 f  PB    N   Y  
   87  m BP   N   N  187 f   BA  N   Y    287 f  PB    N   Y  
   88  m BP   N   N  188 f   BA  N   Y    288 f  PB    N   Y  
   89  m BP   N   N  189 f   BA  N   Y    289 f  PB    N   Y  
   90  m BP   N   N  190 f   BA  N   Y    290 f  PB    N   N  
   91  m BP   N   N  191 f   BA  N   Y    291 f  PB    N   N  
   92  m BP   N   .  192 f   BA  N   Y    292 f  PB    N   .  
   93  m BP   N   N  193 f   BA  N   Y    293 f  PB    N   N  
   94  m BP   N   N  194 f   BA  N   Y    294 f  PB    N   N  
   95  m BP   N   N  195 f   BA  N   Y    295 f  PB    N   N  
   96  m BP   N   N  196 f   BA  N   Y    296 f  PB    N   N  
   97  m BP   N   N  197 f   BA  N   Y    297 f  PB    N   N  
   98  m BP   N   N  198 f   BA  N   N    298 f  PB    N   N  
   99  m BP   N   N  199 f   BA  N   N    299 f  PB    N   N  
  100  m BP   N   .  200 f   BA  N   N    300 f  PB    N   N  
  ;

   data skincross2; 
      set skincross;
      period=1;
      treatment=substr(sequence, 1, 1);
      carryA=0;
      carryB=0;
      response=Time1;
      output;
      period=2;
      Treatment=substr(sequence, 2, 1);
      carrya=(substr(sequence, 1, 1)='A');
      carryb=(substr(sequence, 1, 1)='B');
      response=Time2;
      output;
   run;

   proc genmod data=skincross2 descending; 
      class subject treatment period gender; 
      model response = treatment period carrya carryb 
                       gender gender*period /type3
                       dist=bin link=logit; 
      repeated subject=subject / type=exch;  
   run; 

   proc genmod data=skincross2 descending; 
      class subject treatment period gender; 
      model response = treatment period gender*period  
                       gender /type3
                       dist=bin link=logit; 
      repeated subject=subject / type=exch; 
      estimate 'OR:A-B' treatment 1 -1 0 /exp;
      estimate 'OR:A-P' treatment 1 0 -1 / exp; 
      estimate 'OR:B-P' treatment 0 1 -1 / exp; 
   run; 

   data colds;
      input area gender $ year1 $ year2 $ year3 $ count @@;
       if year1 =' ' and year2 =' ' and year3=' ' then pattern ='mmm';
        else if year1=' ' and year2=' ' then pattern='mmh';
         else if year1=' ' and year3=' ' then pattern= 'mhm';
          else if year2=' ' and year3 =' ' then pattern ='hmm'; 
           else if year1=' ' then pattern= 'mhh';
            else if year2=' ' then pattern='hmh';
             else if year3=' ' then pattern='hhm'; 
              else pattern= 'hhh';
      do i=1 to count; output; end; 
      datalines;
   1 m y y y  80  1 m y y n  46 1 m y n y 38 1 m y n n   61
   1 m n y y  57  1 m n y n  60 1 m n n y 59 1 m n n n  121
   1 m y y .  20  1 m y n .  14 1 m n y . 14 1 m n n .   39
   1 m y . y  16  1 m y . n   5 1 m n . y 15 1 m n . n   13
   1 m . y y  47 1 m . y n   32 1 m . n y 32 1 m . n n   50
   1 m y . . 141 1 m n . .  191 1 m . y . 87 1 m . n .   83
   1 m . . y 156 1 m . . n  173
   1 f y y y 109 1 f y y n   48 1 f y n y 39 1 f y n n   47
   1 f n y y  45 1 f n y n   43 1 f n n y 47 1 f n n n   79
   1 f y y .  34 1 f y n .   10 1 f n y . 19 1 f n n .   28
   1 f y . y  13 1 f y . n    8 1 f n . y 14 1 f n . n    9
   1 f . y y  60 1 f . y n   15 1 f . n y 30 1 f . n n   39
   1 f y . . 170 1 f n . .  155 1 f . y . 91 1 f . n .   84
   1 f . . y 173 1 f . . n  152
   2 m y y y  59 2 m y y n   31 2 m y n y 22 2 m y n n   30
   2 m n y y  35 2 m n y n   15 2 m n n y 41 2 m n n n   55
   2 m y y .  44 2 m y n .   23 2 m n y . 28 2 m n n .   41
   2 m y . y   7 2 m y . n    4 2 m n . y 10 2 m n . n   16
   2 m . y y  26 2 m . y n   26 2 m . n y 23 2 m . n n   22
   2 m y . . 129 2 m n . .  140 2 m . y . 65 2 m . n .   88
   2 m . . y 129 2 m . . n  167
   2 f y y y  94 2 f y y n   31 2 f y n y 11 2 f y n n   32
   2 f n y y  28 2 f n y n   21 2 f n n y 30 2 f n n n   45
   2 f y y .  34 2 f y n .   17 2 f n y . 10 2 f n n .   28
   2 f y . y   9 2 f y . n    4 2 f n . y 6 2 f n . n     6
   2 f . y y  23 2 f . y n   11 2 f . n y 11 2 f . n n    7
   2 f y . . 133 2 f n . .   91 2 f . y . 85 2 f . n .   51
   2 f . . y 116 2 f . . n  113
   ;

   data colds2; set colds;
      drop year1 year2 year3; 
      subject=_n_; 
      resp= year1; year=1; output;
      resp=year2; year=2; output; 
      resp=year3; year=3; output; 
   run; 

   proc genmod; 
      class subject area gender year pattern; 
      model resp = pattern area gender pattern*area pattern*gender
                   year area*gender area*year gender*year/ 
                   dist=bin link=logit type3; 
      repeated subject=subject / type=exch;
   run; 

   proc genmod; 
   class subject area gender year ; 
       model resp = area gender year/ 
                   dist=bin link=logit type3; 
       repeated subject=subject / type=exch;
   run; 

   proc genmod data=resp2 descending;
      class id treatment sex center visit;
      model dichot = center sex treatment age di_base visit
                     / dist=bin type3 link=logit; 
      repeated subject=id*center / logor=exch;
   run;

   proc genmod data=resp2 descending;
      class id treatment sex center visit;
      model dichot = center sex treatment age di_base visit
                     / dist=bin type3 link=logit;
      repeated subject=id*center / logor=logorvar(center) corrw;
   run;

   proc genmod data=resp2 descending;
      class id treatment sex center;
      model dichot = center sex treatment age di_base visit
                     / dist=bin type3 link=logit;
      repeated subject=id*center / logor=fullclust;
   run;

   data dent;
      input patient center trt $ baseline ldose resp @@;
      datalines;
   2   1   ACL  0  5.29832  0 131   1   TL   0  3.91202  2 
   1   1   ACH  1  5.99146  1   3   1   TH   0  4.60517  1 
   130 1   P    0  0.00000  0 132   1   P    0  0.00000  0 
   4   1   P    0  0.00000  0 133   1   P    0  0.00000  0 
   5   1   P    0  0.00000  0 134   2   ACH  0  5.99146  4 
   6   1   TL   1  3.91202  2 135   2   ACL  0  5.29832  4 
   7   1   ACH  0  5.99146  1 136   2   TH   0  4.60517  3 
   8   1   ACL  0  5.29832  0 137   2   ACL  0  5.29832  4 
   9   1   TL   1  3.91202  0 138   2   TL   0  3.91202  3 
  10   1   TL   1  3.91202  4 139   2   P    0  0.00000  4 
  11   1   ACL  0  5.29832  2 140   2   TL   0  3.91202  3 
  12   1   ACH  0  5.99146  0 141   2   TL   0  3.91202  3 
  13   1   P    0  0.00000  0 142   2   ACL  1  5.29832  3 
  14   1   TL   0  3.91202  0 143   2   ACH  0  5.99146  1 
  15   1   P    0  0.00000  0 144   2   ACH  0  5.99146  3 
  16   1   TH   1  4.60517  4 145   2   P    0  0.00000  1 
  17   1   TH   0  4.60517  2 146   2   P    0  0.00000  0 
  18   1   ACH  0  5.99146  1 147   2   ACH  0  5.99146  4 
  19   1   ACL  0  5.29832  0 148   2   TL   0  3.91202  2 
  20   1   TH   0  4.60517  3 149   2   TH   0  4.60517  3 
  21   1   P    1  0.00000  1 150   2   P    0  0.00000  0 
  22   1   TH   1  4.60517  0 151   2   TH   0  4.60517  2 
  23   1   TL   0  3.91202  2 152   2   ACL  1  5.29832  3 
  24   1   ACL  1  5.29832  0 153   2   TH   0  4.60517  2 
  25   1   P    0  0.00000  0 154   2   ACH  0  5.99146  3 
  26   1   ACH  0  5.99146  0 155   2   ACL  0  5.29832  1 
  27   1   ACL  0  5.29832  0 156   2   ACL  0  5.29832  0 
  28   1   P    0  0.00000  0 157   2   ACL  0  5.29832  3 
  29   1   ACH  0  5.99146  2 158   2   TH   0  4.60517  3 
  30   1   TL   0  3.91202  0 159   2   ACL  0  5.29832  1 
  31   1   P    0  0.00000  0 160   2   TL   0  3.91202  3 
  32   1   ACH  0  5.99146  1 161   2   P    0  0.00000  2 
  33   1   TL   0  3.91202  0 162   2   TH   0  4.60517  3 
  34   1   TH   1  4.60517  4 163   2   TH   0  4.60517  4 
  35   1   TL   0  3.91202  2 164   2   ACH  0  5.99146  3 
  36   1   ACH  0  5.99146  0 165   2   TH   0  4.60517  2 
  37   1   ACL  1  5.29832  1 166   2   P    0  0.00000  3 
  38   1   ACL  0  5.29832  3 167   2   ACH  0  5.99146  1 
  39   1   TH   0  4.60517  2 168   2   P    0  0.00000  2 
  40   1   TH   0  4.60517  0 169   2   TL   1  3.91202  2 
  41   1   ACL  0  5.29832  2 170   2   P    0  0.00000  0 
  42   1   TL   0  3.91202  3 171   2   TL   0  3.91202  0 
  43   1   ACL  0  5.29832  2 172   2   TL   0  3.91202  3 
  44   1   ACL  0  5.29832  0 173   2   ACH  1  5.99146  2 
  45   1   TH   0  4.60517  2 174   2   ACL  0  5.29832  3 
  46   1   ACH  0  5.99146  0 175   2   P    0  0.00000  4 
  47   1   P    0  0.00000  0 176   2   TL   1  3.91202  0 
  48   1   ACL  0  5.29832  0 177   2   ACH  0  5.99146  1 
  49   1   TL   0  3.91202  0 178   2   ACH  1  5.99146  2 
  50   1   TL   0  3.91202  2 179   2   ACL  0  5.29832  2 
  51   1   TL   0  3.91202  0 180   2   ACL  0  5.29832  2 
  52   1   ACH  0  5.99146  4 181   2   TH   0  4.60517  2 
  53   1   TH   0  4.60517  4 182   2   TL   0  3.91202  3 
  54   1   TH   0  4.60517  0 183   2   TH   0  4.60517  3 
  55   1   P    0  0.00000  0 184   2   ACH  0  5.99146  1 
  56   1   ACH  0  5.99146  3 185   2   P    0  0.00000  1 
  57   1   ACH  0  5.99146  2 186   2   ACL  0  5.29832  1 
  58   1   P    0  0.00000  0 187   2   TH   0  4.60517  2 
  59   1   TH   0  4.60517  0 188   2   ACH  1  5.99146  3 
  60   1   P    0  0.00000  0 189   2   TH   0  4.60517  2 
  61   1   TL   0  3.91202  1 190   2   TL   0  3.91202  3 
  62   1   P    0  0.00000  0 191   2   P    0  0.00000  1 
  63   1   TH   1  4.60517  1 192   2   TL   0  3.91202  3 
  64   1   TL   0  3.91202  0 193   2   P    0  0.00000  0 
  65   1   ACH  0  5.99146  2 194   2   TH   0  4.60517  2 
  66   1   ACL  0  5.29832  2 195   2   ACH  0  5.99146  4 
  67   1   P    0  0.00000  2 196   2   ACH  0  5.99146  2 
  68   1   TH   0  4.60517  1 197   2   ACL  0  5.29832  3 
  69   1   ACH  0  5.99146  0 198   2   P    0  0.00000  0 
  70   1   P    0  0.00000  0 199   2   P    0  0.00000  3 
  71   1   TL   0  3.91202  0 200   2   ACL  0  5.29832  0 
  72   1   ACH  0  5.99146  2 201   2   ACL  1  5.29832  4 
  73   1   P    0  0.00000  0 202   2   TH   0  4.60517  3 
  74   1   TL   0  3.91202  2 203   2   P    0  0.00000  1 
  75   1   TH   0  4.60517  2 204   2   TH   0  4.60517  1 
  76   1   ACL  1  5.29832  0 205   2   TH   0  4.60517  3 
  77   1   TH   1  4.60517  0 206   2   TL   0  3.91202  3 
  78   1   ACL  0  5.29832  0 207   2   TL   0  3.91202  3 
  79   1   ACL  1  5.29832  3 208   2   TL   0  3.91202  3 
  80   1   ACH  0  5.99146  2 209   2   ACL  0  5.29832  2 
  81   1   ACL  0  5.29832  0 210   2   ACH  0  5.99146  3 
  82   1   P    0  0.00000  0 211   2   TL   1  3.91202  1 
  83   1   TH   0  4.60517  0 212   2   ACH  0  5.99146  3 
  84   1   ACH  0  5.99146  1 213   2   P    0  0.00000  2 
  85   1   TL   0  3.91202  0 214   2   P    0  0.00000  0 
  86   1   TH   0  4.60517  3 215   2   TL   0  3.91202  0 
  87   1   ACH  0  5.99146  0 216   2   TH   0  4.60517  4 
  88   1   P    0  0.00000  0 217   2   ACH  0  5.99146  2 
  89   1   ACH  0  5.99146  1 218   2   P    0  0.00000  0 
  90   1   TL   0  3.91202  0 219   2   TH   0  4.60517  2 
  91   1   ACL  0  5.29832  1 220   2   TL   0  3.91202  1 
  92   1   TH   0  4.60517  0 221   2   ACH  0  5.99146  2 
  93   1   ACL  0  5.29832  1 222   2   TL   0  3.91202  4 
  94   1   TL   1  3.91202  1 223   2   TH   0  4.60517  2 
  95   1   TL   1  3.91202  3 224   2   TH   1  4.60517  1 
  96   1   P    0  0.00000  0 225   2   ACH  0  5.99146  1 
  97   1   TH   0  4.60517  0 226   2   ACL  0  5.29832  4 
  98   1   ACL  0  5.29832  0 227   2   P    1  0.00000  3 
  99   1   P    1  0.00000  0 228   2   ACL  0  5.29832  2 
 100   1   ACH  0  5.99146  2 229   2   TL   0  3.91202  0 
 101   1   TH   0  4.60517  0 230   2   ACL  0  5.29832  1 
 102   1   TL   0  3.91202  0 231   2   ACH  0  5.99146  3 
 103   1   ACL  0  5.29832  1 232   2   ACL  0  5.29832  3 
 104   1   TL   0  3.91202  0 233   2   P    0  0.00000  1 
 105   1   P    0  0.00000  1 234   2   ACL  0  5.29832  4 
 106   1   ACL  0  5.29832  0 235   2   ACH  0  5.99146  1 
 107   1   TH   1  4.60517  2 236   2   TH   0  4.60517  1 
 108   1   P    0  0.00000  0 237   2   ACL  0  5.29832  0 
 109   1   ACH  0  5.99146  1 238   2   ACL  1  5.29832  4 
 110   1   TH   1  4.60517  1 239   2   ACL  0  5.29832  3 
 111   1   TL   0  3.91202  0 240   2   P    0  0.00000  0 
 112   1   ACH  0  5.99146  0 241   2   P    1  0.00000  3 
 113   1   TL   0  3.91202  0 242   2   TL   0  3.91202  2 
 114   1   ACH  0  5.99146  1 243   2   P    0  0.00000  0 
 115   1   P    0  0.00000  0 244   2   TH   0  4.60517  3 
 116   1   ACL  0  5.29832  0 245   2   TL   1  3.91202  4 
 117   1   P    0  0.00000  0 246   2   ACH  1  5.99146  1 
 118   1   ACH  0  5.99146  3 247   2   P    0  0.00000  1 
 119   1   TH   0  4.60517  3 248   2   TH   0  4.60517  4 
 120   1   ACL  0  5.29832  2 249   2   TL   0  3.91202  0 
 121   1   TH   0  4.60517  2 250   2   TL   0  3.91202  3 
 122   1   TH   0  4.60517  1 251   2   ACH  0  5.99146  3 
 123   1   TL   0  3.91202  0 252   2   TH   0  4.60517  3 
 124   1   ACH  0  5.99146  0 253   2   ACH  0  5.99146  1 
 125   1   ACL  0  5.29832  0 254   2   TH   0  4.60517  3 
 126   1   TH   1  4.60517  0 255   2   ACL  0  5.29832  0 
 127   1   ACL  0  5.29832  0 256   2   TL   0  3.91202  3 
 128   1   ACH  0  5.99146  1 257   2   P    0  0.00000  1 
 129   1   ACL  0  5.29832  3 258   2   ACH  0  5.99146  3 
; 

   proc logistic data=dent descending; 
      class patient center baseline trt;
      model resp = center baseline trt;
   run; 

   proc freq data=dent; 
       tables center*resp baseline*resp trt*resp /
          nocol norow nopct; 
   run; 

   data dent2; set dent;
      do;  if resp=4 then presp =1; 
      else presp=0; logtype=4; output; end;
      do; if resp=4 or resp=3 then presp=1; 
      else presp=0; logtype=3 ; output; end; 
      do; if resp=4 or resp=3 or resp=2 then presp=1;
      else presp=0; logtype=2; output; end;
      do; if resp=4 or resp=3 or resp=2 or resp=1 then presp=1;
      else presp=0; logtype=1; output; end; 
   run;

   proc genmod descending order=data; 
      class logtype patient center baseline trt;
      model presp = center baseline trt logtype
          logtype*center logtype*baseline logtype*trt / 
          link=logit dist=bin type3; 
      repeated subject=patient / type=unstr; 
   run;

   proc genmod descending order=data; 
      class logtype patient center baseline trt;
      model presp = center trt baseline logtype
                    logtype*center logtype*trt / 
                    link=logit dist=bin type3; 
      repeated subject=patient / type=unstr; 
   run;

   data lri;
      input id count risk passive crowding ses agegroup race @@;
      logrisk =log(risk/52);
      datalines;  
   1 0 42 1 0 2 2 0 96 1 41 1 0 1 2 0   191 0 44 1 0 0 2 0 
   2 0 43 1 0 0 2 0 97 1 26 1 1 2 2 0   192 0 45 0 0 0 2 1  
   3 0 41 1 0 1 2 0 98 0 36 0 0 0 2 0   193 0 42 0 0 0 2 0  
   4 1 36 0 1 0 2 0 99 0 34 0 0 0 2 0   194 1 31 0 0 0 2 1  
   5 1 31 0 0 0 2 0 100 1  3 1 1 2 3 1  195 0 35 0 0 0 2 0  
   6 0 43 1 0 0 2 0 101 0 45 1 0 0 2 0  196 1 35 1 0 0 2 0  
   7 0 45 0 0 0 2 0 102 0 38 0 0 1 2 0  197 1 27 1 0 1 2 0  
   8 0 42 0 0 0 2 1 103 0 41 1 1 1 2 1  198 1 33 0 0 0 2 0  
   9 0 45 0 0 0 2 1 104 1 37 0 1 0 2 0  199 0 39 1 0 1 2 0  
  10 0 35 1 1 0 2 0 105 0 40 0 0 0 2 0  200 3 40 0 1 2 2 0  
  11 0 43 0 0 0 2 0 106 1 35 1 0 0 2 0  201 4 26 1 0 1 2 0  
  12 2 38 0 0 0 2 0 107 0 28 0 1 2 2 0  202 0 14 1 1 1 1 1  
  13 0 41 0 0 0 2 0 108 3 33 0 1 2 2 0  203 0 39 0 1 1 2 0  
  14 0 12 1 1 0 1 0 109 0 38 0 0 0 2 0  204 0  4 1 1 1 3 0  
  15 0  6 0 0 0 3 0 110 0 42 1 1 2 2 1  205 1 27 1 1 1 2 1  
  16 0 43 0 0 0 2 0 111 0 40 1 1 2 2 0  206 0 36 1 0 0 2 1  
  17 2 39 1 0 1 2 0 112 0 38 0 0 0 2 0  207 0 30 1 0 2 2 1  
  18 0 43 0 1 0 2 0 113 2 37 0 1 1 2 0  208 0 34 0 1 0 2 0  
  19 2 37 0 0 0 2 1 114 1 42 0 1 0 2 0  209 1 40 1 1 1 2 0  
  20 0 31 1 1 1 2 0 115 5 37 1 1 1 2 1  210 0  6 1 0 1 1 1  
  21 0 45 0 1 0 2 0 116 0 38 0 0 0 2 0  211 1 40 1 1 1 2 0  
  22 1 29 1 1 1 2 1 117 0  4 0 0 0 3 0  212 2 43 0 1 0 2 0  
  23 1 35 1 1 1 2 0 118 2 37 1 1 1 2 0  213 0 36 1 1 1 2 0  
  24 3 20 1 1 2 2 0 119 0 39 1 0 1 2 0  214 0 35 1 1 1 2 1  
  25 1 23 1 1 1 2 0 120 0 42 1 1 0 2 0  215 1 35 1 1 2 2 0  
  26 1 37 1 0 0 2 0 121 0 40 1 0 0 2 0  216 0 43 1 0 1 2 0  
  27 0 49 0 0 0 2 0 122 0 36 1 0 0 2 0  217 0 33 1 1 2 2 0  
  28 0 35 0 0 0 2 0 123 1 42 0 1 1 2 0  218 0 36 0 1 1 2 1  
  29 3 44 1 1 1 2 0 124 1 39 0 0 0 2 0  219 1 41 0 0 0 2 0  
  30 0 37 1 0 0 2 0 125 2 29 0 0 0 2 0  220 0 41 1 1 0 2 1  
  31 2 39 0 1 1 2 0 126 3 37 1 1 2 2 1  221 1 42 0 0 0 2 1  
  32 0 41 0 0 0 2 0 127 0 40 1 0 0 2 0  222 0 33 0 1 2 2 1  
  33 1 46 1 1 2 2 0 128 0 40 0 0 0 2 0  223 0 40 1 1 2 2 0  
  34 0  5 1 1 2 3 1 129 0 39 0 0 0 2 0  224 0 40 1 1 1 2 1  
  35 1 29 0 0 0 2 0 130 0 40 1 0 1 2 0  225 0 40 0 0 2 2 0  
  36 0 31 0 1 0 2 0 131 1 32 0 0 0 2 0  226 0 28 1 0 1 2 0  
  37 0 22 1 1 2 2 0 132 0 46 1 0 1 2 0  227 0 47 0 0 0 2 1  
  38 1 22 1 1 2 2 1 133 4 39 1 1 0 2 0  228 0 18 1 1 2 2 1  
  39 0 47 0 0 0 2 0 134 0 37 0 0 0 2 0  229 0 45 1 0 0 2 0  
  40 1 46 1 1 1 2 1 135 0 51 0 0 1 2 0  230 0 35 0 0 0 2 0  
  41 0 37 0 0 0 2 0 136 1 39 1 1 0 2 0  231 1 17 1 0 1 1 1  
  42 1 39 0 0 0 2 0 137 1 34 1 1 0 2 0  232 0 40 0 0 0 2 0  
  43 0 33 0 1 1 2 1 138 1 14 0 1 0 1 0  233 0 29 1 1 2 2 0  
  44 0 34 1 0 1 2 0 139 2 15 1 0 0 2 0  234 1 35 1 1 1 2 0  
  45 3 32 1 1 1 2 0 140 1 34 1 1 0 2 1  235 0 40 0 0 2 2 0  
  46 3 22 0 0 0 2 0 141 0 43 0 1 0 2 0  236 1 22 1 1 1 2 0  
  47 1  6 1 0 2 3 0 142 1 33 0 0 0 2 0  237 0 42 0 0 0 2 0  
  48 0 38 0 0 0 2 0 143 3 34 1 0 0 2 1  238 0 34 1 1 1 2 1  
  49 1 43 0 1 0 2 0 144 0 48 0 0 0 2 0  239 6 38 1 0 1 2 0  
  50 2 36 0 1 0 2 0 145 4 26 1 1 0 2 0  240 0 25 0 0 1 2 1  
  51 0 43 0 0 0 2 0 146 0 30 0 1 2 2 1  241 0 39 0 1 0 2 0  
  52 0 24 1 0 0 2 0 147 0 41 1 1 1 2 0  242 1 35 0 1 2 2 1  
  53 0 25 1 0 1 2 1 148 0 34 0 1 1 2 0  243 1 36 1 1 1 2 1  
  54 0 41 0 0 0 2 0 149 0 43 0 1 0 2 0  244 0 23 1 0 0 2 0  
  55 0 43 0 0 0 2 0 150 1 31 1 0 1 2 0  245 4 30 1 1 1 2 0  
  56 2 31 0 1 1 2 0 151 0 26 1 0 1 2 0  246 1 41 1 1 1 2 1  
  57 3 28 1 1 1 2 0 152 0 37 0 0 0 2 0  247 0 37 0 1 1 2 0  
  58 1 22 0 0 1 2 1 153 0 44 0 0 0 2 0  248 0 46 1 1 0 2 0  
  59 1 11 1 1 1 1 0 154 0 40 1 0 0 2 0  249 0 45 1 1 0 2 1  
  60 3 41 0 1 1 2 0 155 0  8 1 1 1 3 1  250 1 38 1 1 1 2 0  
  61 0 31 0 0 1 2 0 156 0 40 1 1 1 2 1  251 0 10 1 1 1 1 0  
  62 0 11 0 0 1 1 1 157 1 45 0 0 0 2 0  252 0 30 1 1 2 2 0  
  63 0 44 0 1 0 2 0 158 0  4 0 0 2 3 0  253 0 32 0 1 2 2 0  
  64 0  9 1 0 0 3 1 159 1 36 0 1 0 2 0  254 0 46 1 0 0 2 0  
  65 0 36 1 1 1 2 0 160 3 37 1 1 1 2 0  255 5 35 1 1 2 2 1  
  66 0 29 1 0 0 2 0 161 0 15 1 0 0 1 0  256 0 44 0 0 0 2 0  
  67 0 27 0 1 0 2 1 162 1 27 1 0 1 2 1  257 0 41 0 1 1 2 0  
  68 0 36 0 1 0 2 0 163 2 31 0 1 0 2 0  258 2 36 1 0 1 2 0  
  69 1 33 1 0 0 2 0 164 0 42 0 0 0 2 0  259 0 34 1 1 1 2 1  
  70 2 13 1 1 2 1 1 165 0 42 1 0 0 2 0  260 1 30 0 1 0 2 1  
  71 0 38 0 0 0 2 0 166 1 38 0 0 0 2 0  261 1 27 1 0 0 2 0  
  72 0 41 0 0 0 2 1 167 0 44 1 0 0 2 0  262 0 48 1 0 0 2 0  
  73 0 41 1 0 2 2 0 168 0 45 0 0 0 2 0  263 1  6 0 1 2 3 1  
  74 0 35 0 0 1 2 0 169 0 34 0 1 0 2 0  264 0 38 1 1 0 2 1  
  75 0 45 0 0 0 2 0 170 2 41 0 0 0 2 0  265 0 29 1 1 1 2 1  
  76 4 38 1 0 2 2 1 171 2 30 1 1 1 2 0  266 1 43 0 1 2 2 1  
  77 1 42 1 0 0 2 1 172 0 44 0 0 0 2 0  267 0 43 0 1 0 2 0  
  78 1 42 1 1 2 2 1 173 0 40 1 0 0 2 0  268 0 37 1 0 2 2 0  
  79 6 36 1 1 0 2 0 174 2 31 0 0 0 2 0  269 1 23 1 1 0 2 1  
  80 2 23 1 1 1 2 1 175 0 41 1 0 0 2 0  270 0 44 0 0 1 2 0  
  81 1 32 0 0 1 2 0 176 0 41 0 0 0 2 0  271 0  5 0 1 1 3 1  
  82 0 41 0 1 0 2 0 177 0 39 1 0 0 2 0  272 0 25 1 0 2 2 0  
  83 0 50 0 0 0 2 0 178 0 40 1 0 0 2 0  273 0 25 1 0 1 2 0  
  84 0 42 1 1 1 2 1 179 2 35 1 0 2 2 0  274 1 28 1 1 1 2 1  
  85 1 30 0 0 0 2 0 180 1 43 1 0 0 2 0  275 0  7 0 1 0 3 1  
  86 2 47 0 1 0 2 0 181 2 39 0 0 0 2 0  276 0 32 0 0 0 2 0  
  87 1 35 1 1 2 2 0 182 0 35 1 1 0 2 0  277 0 41 0 0 0 2 0  
  88 1 38 1 0 1 2 1 183 0 37 0 0 0 2 0  278 1 33 1 1 2 2 1  
  89 1 38 1 1 1 2 1 184 3 37 0 0 0 2 0  279 2 36 1 1 2 2 0  
  90 1 38 1 1 1 2 1 185 0 43 0 0 0 2 0  280 0 31 0 0 0 2 0  
  91 0 32 1 1 1 2 0 186 0 42 0 0 0 2 0  281 0 18 0 0 0 2 0  
  92 1  3 1 0 1 3 1 187 0 42 0 0 0 2 0  282 1 32 1 0 2 2 0  
  93 0 26 1 0 0 2 1 188 0 38 0 0 0 2 0  283 0 22 1 1 2 2 1  
  94 0 35 1 0 0 2 0 189 0 36 1 0 0 2 0  284 0 35 0 0 0 2 1  
  95 3 37 1 0 0 2 0 190 0 39 0 1 0 2 0 
  ;

   proc genmod data=lri;
      class ses id race agegroup; 
      model count = passive crowding ses race agegroup/
                    dist=poisson link=log offset=logrisk type3;
   run;

   proc genmod data=lri;
      class id ses race agegroup; 
      model count = passive crowding ses race agegroup /
                    dist=poisson link=log offset=logrisk type3;
      repeated subject=id / type=ind;
   run;


Statistics and Operations Research