FOCUS AREAS

Graphics

Distribution of ASAT by Time and Treatment
Base SAS: Graph Template Language

%let graphs='.';
%let dpi=100;
%let w=8in;
%let h=4.5in;

option missing=' ';

/*--Generate simulated data for value, at-risk and Over2 by week and drug--*/
data asat_group;
  drop i;
  format AtRisk 3.0 Over2 1.0;
  label Value='ASAT (/ULN)';
  do Week=0, 1, 2, 4, 8, 12, 24, 26;
    do Drug='Drug A', 'Drug B';
       if Drug eq 'Drug A' then Over2Label='<2 (A)';
       else Over2Label='<2 (B)';
       Over2=floor(4*ranuni(3));

       if Drug eq 'Drug A' then do;
          if week = 26 then AtRisk=340;
          else if week > 0 then AtRisk=300/sqrt(week);
          else AtRisk=325;
         end;
       else do;
          if week = 26 then AtRisk=230;
          else if week > 0 then AtRisk=200/sqrt(week);
          else AtRisk=220;
         end;

         do i=1 to 20;
            Value=0.5*ranuni(2);
            output;
            Over2=.; Over2Label=''; AtRisk=.;
         end;
         do i=1 to 5;
            Value=2*ranuni(2);
            output;
         end;
    end;
  end;
run;

/*--Create statgraph template for ASAT graph--*/
proc template;
define statgraph Asat_Group;
  dynamic _weights;
  begingraph;
   entrytitle 'Distribution of ASAT by Time and Treatment';

   /*--Use a three column LATTICE layout with uniform column data range with weights--*/
   layout lattice / columns=1 COLUMNDATARANGE=UNION rowweights=_weights rowgutter=1px;

    /*--Define one common column--*/
    columnaxes;
      columnaxis / display=(ticks tickvalues) type=linear linearopts=(tickvaluelist=(0 1 2 4 8 12 24 26));
    endcolumnaxes;

    /*--Define upper cell with the over 2 counts--*/
    layout overlay / yaxisopts=(display=(tickvalues));     
      scatterplot x=week y=over2label / group=Drug
        markercharacter=over2 markercharacterattrs=(weight=bold);
      referenceline x=25 / lineattrs=(pattern=solid); 
    endlayout;

    /*--Define middle cell box plot--*/
    /*--Note:  For SAS 9.3, TYPE=LINEAR is necessary in the X axis options--*/
    layout overlay / xaxisopts = (type=linear display=(tickvalues label));
      boxplot x=week y=value  / group=drug name="d" whiskerattrs=(thickness=2)   
        groupdisplay=cluster display=(mean median outliers)
        outlierattrs=(size=8 weight=bold) outlineattrs=(thickness=2);
      referenceline x=25 / lineattrs=(pattern=solid);
      referenceline y=1.0 / lineattrs=(pattern=shortdash);
      referenceline y=2.0 / lineattrs=(pattern=dash);
      referenceline y=0 / lineattrs=(pattern=dash);
    endlayout;

    /*--Define last cell with at-risk values--*/
    layout overlay /  yaxisopts=(display=(tickvalues));     
      scatterplot x=week y=drug / group=Drug 
        markercharacter=atrisk markercharacterattrs=(weight=bold); 
      referenceline x=25 / lineattrs=(pattern=solid); 
    endlayout;

    /*--Add common legend at the bottom--*/
    sidebar / align=bottom spacefill=false;
      discretelegend 'd';
    endsidebar;

   endLayout;
  endgraph;
end;
run;

/*--Create ASAT graph with row weights pof 8%, 84% and 8%--*/
ods listing style=htmlblue gpath=&graphs image_dpi=&dpi;
ods graphics / reset width=&w height=&h imagename="ASAT_Group_V93";
proc sgrender data=asat_group template=Asat_Group;
  dynamic _weights='0.08 0.84 0.08';
run;