Modifying the Axes

The template option linearopts=(viewmin=0 viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)) controls the minimum value displayed, the maximum value displayed, and the ticks on the vertical axis. You can change the range of the vertical axis or the ticks in either version of the template by changing this option everywhere that it occurs. The following specification changes the ticks but not the range of values: linearopts=(viewmin=0 viewmax=1 tickvaluelist=(0 .25 .5 .75 1.0)).

When there is a single stratum, the LAYOUT OVERLAY statement (which controls the axes) is as follows:

layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05
   linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
   tickvaluefitpolicy=XTICKVALFITPOL)) yaxisopts=(label=
   "Survival Probability" shortlabel="Survival" linearopts=(viewmin=
   0 viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)));

The LAYOUT OVERLAY statement with more than one stratum is identical. With added comments, the statement is as follows:

layout overlay /                          /*-----------------------------*/
          xaxisopts=(                     /* X axis options              */
                                          /* label= is not specified, so */
                                          /* it comes from data object   */
                                          /* column label                */
             shortlabel=XNAME             /* alternative shorter label   */
                                          /* comes from dynamic          */
             offsetmin=.05                /* add 5% padding on minimum   */
                                          /* side of the x axis          */
             linearopts=(                 /* linear axis (not log axis)  */
                viewmax=MAXTIME           /* largest value to display,   */
                                          /* comes from dynamic          */
                tickvaluelist=XTICKVALS   /* tick value list comes from  */
                                          /* a dynamic                   */
                tickvaluefitpolicy=       /* fit policy comes from a     */
                   XTICKVALFITPOL))       /* dynamic - controls tick     */
                                          /* value collision avoidance   */
                                          /* strategies including        */
                                          /* rotation                    */
                                          /*-----------------------------*/
          yaxisopts=(                     /* Y axis options              */
             label="Survival Probability" /* axis label                  */
             shortlabel="Survival"        /* shorter label for short axes*/
             linearopts=(                 /* linear axis (not log axis)  */
                viewmin=0                 /* smallest value to display   */
                viewmax=1                 /* largest value to display    */
                tickvaluelist=            /* list of tick values to      */
                   (0 .2 .4 .6 .8 1.0))); /* display                     */
                                          /*-----------------------------*/

You can change any of these values in several ways:

  • You can specify literal values or macro variables when previously a dynamic variable was used. Example: change VIEWMAX=MAXTIME to VIEWMAX=2000.

  • You can change literal specifications. Example: change VIEWMAX=1 TICKVALUELIST= (0 .2 .4 .6 .8 1.0) to VIEWMAX=0.75 TICKVALUELIST=(0 .25 .5 .75) to restrict the range on the Y axis.

  • You can add options. Example: specify LABEL="Time" in the XAXISOPTS= option. Example: specify LABELATTRS=(SIZE=12PX) in the XAXISOPTS= and YAXISOPTS= options to change the font size for the labels. Example: specify TICKVALUEATTRS=(SIZE=10PX) in the XAXISOPTS= and YAXISOPTS= options to change the font size for the ticks.

  • You can delete options. Example: delete VIEWMIN=0 VIEWMAX=1 from the YAXISOPTS= option.

If you frequently find yourself changing the title or the axes, you can make it easier by creating a template where those options are controlled by macro variables. For example, this template is easier to modify than the default template:

%let TitleText0 = METHOD " Survival Estimate";
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0 "s";
%let yOptions   = label="Survival Probability"
                  shortlabel="Survival"
                  linearopts=(viewmin=0 viewmax=1
                              tickvaluelist=(0 .2 .4 .6 .8 1.0));
%let xOptions   = shortlabel=XNAME
                  offsetmin=.05
                  linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
                              tickvaluefitpolicy=XTICKVALFITPOL);
proc template;
   define statgraph Stat.Lifetest.Graphics.ProductLimitSurvival;
      dynamic NStrata xName plotAtRisk plotCensored plotCL plotHW plotEP labelCL
         labelHW labelEP maxTime xtickVals xtickValFitPol method StratumID
         classAtRisk plotBand plotTest GroupName yMin Transparency SecondTitle
         TestName pValue;
      BeginGraph;
         if (NSTRATA=1)
            if (EXISTS(STRATUMID))
               entrytitle &titletext1;
            else
               entrytitle &titletext0;
            endif;
            if (PLOTATRISK=1)
               entrytitle "with Number of Subjects at Risk" / textattrs=
                  GRAPHVALUETEXT;
            endif;
            layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
               .
               .
               .
            endlayout;
         else
            entrytitle &titletext2;
            if (EXISTS(SECONDTITLE))
               entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
            endif;
            layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
               .
               .
               .
            endlayout;
         endif;
      EndGraph;
   end;
run;