FOCUS AREAS

Graphics

Hazard Function for Adverse Events of Special Interest
Base SAS: Graph Template Language

%let graphs='.';

%let dpi=100;
%let w=8in;
%let h=4.5in;

data hazard;
  input day A ALow AHigh ARisk B BLow BHigh BRisk;
  label day='Days since randomization';
  label A='Drug A';
  label B='Drug B';
  label ARisk='Drug A';
  label BRisk='Drug B';
  datalines;
 0   .      .      .      .    .      .      .       . 
10   .0005  .0001  .0009  212  .0078  .007   .0086   428
30   .0007  .0002  .0012  199  .0026  .002   .0032   339
50   .0005  .0001  .0009  189  .0005  .0002  .0008   309
70   .0004  .0001  .0007  183  .001   .0006  .0014   297
90   .0001  .      .      178  .0008  .0005  .0011   285
110  .0003  .0001  .0005  175  .0002  .0001  .0003   276
130  .0003  .0001  .0005  168  .0002  .0001  .0003   271
150  .0003  .0001  .0005  162  .0002  .0001  .0003   264
170  .0005  .0001  .0009   93  .001   .0005  .0015   148
190  .0     .0     .0      13  .003   .0     .006     19 
200  .      .      .      .    .      .      .       . 
  ;
  run;

data hazard_Group;
  set hazard;
  keep Day Drug Value Risk High Low;
  Drug='Drug A'; Value=a; Risk=Arisk; High=Ahigh; Low=Alow; output;
  Drug='Drug B'; Value=b; Risk=Brisk; High=Bhigh; Low=Blow; output;
  run;
/*proc print;run;*/

/*--Define template for graph--*/
proc template;
  define statgraph hazard_function;
    dynamic _icon _thick;
    begingraph / designwidth=6in designheight=4.5in;
      entrytitle 'Hazard Function for Adverse Events of Special Interest';
      layout overlay / yaxisopts=(label='Hazard Rate')
          xaxisopts=(linearopts=(viewmin=0 
                     tickvaluelist=(0 20 40 60 80 100 120 140 160 180 200)));
        stepplot x=day y=A / errorupper=AHigh errorlower=ALow justify=center 
          lineattrs=graphdata1(thickness=_thick) 
          errorbarattrs=graphdata1(thickness=_thick) name='a';
        stepplot x=day y=B / errorupper=BHigh errorlower=BLow justify=center
          lineattrs=graphdata2(thickness=_thick) 
          errorbarattrs=graphdata2(thickness=_thick) name='b';
        discretelegend 'a' 'b' / location=inside halign=right valign=top across=1 border=true;
        innermargin;
          blockplot x=day block=BRisk / display=(values label) valuehalign=start labelattrs=GraphData2 valueattrs=GraphData2;
	  blockplot x=day block=ARisk / display=(values label) valuehalign=start labelattrs=GraphData1 valueattrs=GraphData1 ;
        endinnermargin;
     endlayout;
     if (exists(_icon) eq 0)
       entryfootnote halign=left 'Table:  Average number of subjects at risk during interval';
     endif;
  endgraph;
end;
run;

/*--Render graph--*/
ods listing style=htmlblue gpath=&graphs image_dpi=&dpi;
ods graphics / reset width=&w height=&h imagename="HazardFunction_V93";
proc sgrender data=hazard template=hazard_function;
  dynamic _thick=2;
run;