Event Table Macros

All the macros and macro variables that have been described up to this point are used in defining the two survival plot graph templates. Some macros (%StmtsTop and %StmtsBottom) and macro variables (StepOpts and GraphOpts) are null and do not affect the generated template code, but all are resolved somewhere in the process of producing the templates. In contrast, the macros %SurvTabHeader, %SurvivalTable, and %SurvivalSummaryTable are not used by default. They are available for you to use to add more statements to the templates.

The %SurvTabHeader macro provides the headings for the event table:

%macro SurvTabHeader(multiple);
   %if &multiple %then %do; entry ""; %end;
   entry "";
   entry &r "Median";
   entry "";

   %if &multiple %then %do; entry ""; %end;
   entry &r "Subjects";
   entry &r "Event";
   entry &r "Censored";
   entry &r "Survival";
   entry &r PctMedianConfid;
   entry halign=left  "CL";
%mend;

This table is not displayed by default. There are two types of headings: one for multiple strata and one for a single stratum.

The %SurvivalTable macro provides the body of the event table:

%macro SurvivalTable;
   %local fmt r i t;
   %let fmt = bestd6.;
   %let r = halign = right;
   columnheaders;
      layout overlay / pad=(top=5);
         if(NSTRATA=1)
            layout gridded / columns=6 border=TRUE;
               dynamic PctMedianConfid NObs NEvent Median
                       LowerMedian UpperMedian;
               %SurvTabHeader(0)
               entry &r NObs;
               entry &r NEvent;
               entry &r eval(NObs-NEvent);
               entry &r eval(put(Median,&fmt));
               entry &r eval(put(LowerMedian,&fmt));
               entry &r eval(put(UpperMedian,&fmt));
            endlayout;
         else
            layout gridded / columns=7 border=TRUE;
               dynamic PctMedianConfid;
               %SurvTabHeader(1)
               %do i = 1 %to 10;
                  %let t = / textattrs=GraphData&i;
                  dynamic StrVal&i NObs&i NEvent&i Median&i
                          LowerMedian&i UpperMedian&i;
                  if (&i <= nstrata)
                     entry &r StrVal&i &t;
                     entry &r NObs&i &t;
                     entry &r NEvent&i &t;
                     entry &r eval(NObs&i-NEvent&i) &t;
                     entry &r eval(put(Median&i,&fmt)) &t;
                     entry &r eval(put(LowerMedian&i,&fmt)) &t;
                     entry &r eval(put(UpperMedian&i,&fmt)) &t;
                  endif;
               %end;
            endlayout;
         endif;
      endlayout;
   endcolumnheaders;
%mend;

The %SurvivalSummaryTable macro redefines the %AtRiskLatticeStart and %AtRiskLatticeEnd macros so that they provide the body of the event table:

%macro SurvivalSummaryTable;
   %macro AtRiskLatticeStart;
      layout lattice / columndatarange=union rowgutter=10
         rows=%if &outside %then 2 rowweights=ROWWEIGHTS;
              %else              1;;
      %if &outside %then %do; cell; %end;
   %mend;

   %macro AtRiskLatticeEnd(useclassopts);
      %if &outside %then %do;
         endcell;
         cell;
            layout overlay / walldisplay=none xaxisopts=(display=none);
               axistable x=TATRISK value=ATRISK / &atriskopts
                         %if &useclassopts ne %then &classopts;;
            endlayout;
         endcell;
      %end;
      %SurvivalTable
      endlayout;
   %mend;
%mend;

If you want to create an event table like the one displayed in Figure 23.30, you only need to call the %SurvivalSummaryTable macro. If you want to modify the table, then you need to modify the %SurvTabHeader and %SurvivalTable macros.