BackForward
libname mytmpl 'J:\CLINICAL\TACHY\BIOSTAT\Duo\myownsetting\template';

%let today=%sysfunc(datetime(), datetime20.);
proc contents data=ridcrf.aedvn out=aecnt noprint;
run;
data tmp;
   do i=n;
   set aecnt point=i nobs=n;
   output;
   call symput('cutoffdt', put(modate, datetime20.));
   end;
   stop;
run;

ods path sashelp.tmplmst(read) mytmpl.tmplmst(update);
title1 "RID-AF Adverse Event Summary";
title3 "Database Cut-off Time: &cutoffdt";
footnote2 "(report generated: &today)";
proc format;
  value relatef 1='Related'
                2='Not related'
                3 = 'Unknown';
run;
proc template;
   define table ae.tmpl;
      balance=on;
      center=on;
      newpage=off;
      panels=12;
      style=timestyle;
      /*COL_SPACE_MAX=2;*/
      /*wrap=on;*/

      translate _val_=. into 'No data';

      notes "NMVAR defines symbols that will be used";
      notes "to determine the colors of the cells.";

      /* mvar today cutoffdt;*/
      column pt implantsys idate aedate compobs keyterm aedscp actiondscp outcome impsysn improcn logindate;
      classlevels=on;
         double_space=on;
         overline=on;
         underline=on;

      header table_header_1;

      define table_header_1;
         /*text "RID-AF Adverse Event Summary";*/
         width=1;
         style=header{font_size=6};
      end;

      /*define table_header_2;
         text "Database Cut-off Time: " cutoffdt " ";
         space=1;
      end;*/

      /*define footer table_footer;
         text "(report generated: " today ")";
         split="*";
         style=header{font_size=2};
      end;*/

      define pt;
         generic=on;
         style=timestyle;
         id=on;
         just=c;
         vjust=c;
         merge=off;
         width_max=6;
         format_width=6;
         separator='';
         header=_label_;
      end;
      define implantsys;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=11;
         format_width=11;
         separator='';
         header="Implanted System";
      end;
      define idate;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=11;
         format=mmddyy10.;
         format_width=11;
         separator='';
         header=_label_;
      end;
      define aedate;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=11;
         format=mmddyy10.;
         format_width=11;
         separator='';
         header=_label_;
      end;
      define compobs;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=12;
         format_width=12;
         separator='';
         header=_label_;
      end;
      define keyterm;
         generic=on;
         style=timestyle;
         just=l;
         vjust=c;
         width_max=10;
         format_width=10;
         flow=on;
         maximize=on;
         separator='';
         header=_label_;
      end;
      define aedscp;
         generic=on;
         style=timestyle;
         just=l;
         vjust=t;
         width_max=24;
         format_width=24;
         flow=on;
         maximize=on;
         separator='';
         header=_label_;
      end;
      define actiondscp;
         generic=on;
         style=timestyle;
         just=l;
         vjust=t;
         flow=on;
         maximize=on;
         WIDTH_MAX=20;
         format_width=20;
         separator='';
         header=_label_;
      end;
      define outcome;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=9;
         format_width=9;
         separator='';
         header=_label_;
      end;
      define impsysn;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=9;
         format=relatef.;
         format_width=11;
         separator='';
         header=_label_;
      end;
      define improcn;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=9;
         format=relatef.;
         format_width=11;
         separator='';
         header=_label_;
      end;
      define logindate;
         generic=on;
         style=timestyle;
         just=c;
         vjust=c;
         width_max=11;
         format=mmddyy10.;
         format_width=11;
         separator='';
         header=_label_;
      end;
   end;
run;