This sample illustrates how to change the range of the X and Y axis on a survival plot that is produced with ODS Graphics and PROC LIFETEST.
See the LINEAROPTS= option within the YAXISOPTS= and XAXISOPTS= options in the LAYOUT OVERLAY statement in the Stat.Lifetest.Graphics.ProductLimitSurvival template for the syntax.
Please note that SAS/GRAPH® and SAS/STAT® are required in order to run this sample program.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
This sample illustrates how to change the range of the X and Y axis on a survival plot that is produced with ODS Graphics and PROC LIFETEST.
See the LINEAROPTS= option within the YAXISOPTS= and XAXISOPTS= options in the LAYOUT OVERLAY statement in the Stat.Lifetest.Graphics.ProductLimitSurvival template for the syntax.
Please note that SAS/GRAPH® and SAS/STAT® are required in order to run this sample program.
proc template;
define statgraph Stat.Lifetest.Graphics.ProductLimitSurvival;
dynamic NStrata xName plotAtRisk plotCensored plotCL plotHW plotEP
labelCL labelHW labelEP maxTime StratumID classAtRisk plotBand
plotTest GroupName yMin Transparency SecondTitle TestName pValue;
begingraph;
if (NSTRATA=1)
if (EXISTS(STRATUMID))
entrytitle "Product-Limit Survival Estimate" " for " STRATUMID;
else
entrytitle "Product-Limit Survival Estimate";
endif;
if (PLOTATRISK)
entrytitle "with Number of Subjects at Risk" / textattrs=
GRAPHVALUETEXT;
endif;
/* Original syntax */
* layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05 linearopts
=(viewmax=MAXTIME)) yaxisopts=(label="Survival Probability"
shortlabel="Survival" linearopts=(viewmin=0 viewmax=1
tickvaluelist=(0 .2 .4 .6 .8 1.0)));
/* Modified syntax - modify axes */
layout overlay /
xaxisopts=(shortlabel=XNAME offsetmin=.05
linearopts=(viewmax=80 tickvaluelist=(0 10 20 30 40 50 60 70 80)))
yaxisopts=(label="Survival Probs" shortlabel="Survival"
linearopts=(viewmin=.25 viewmax=1 tickvaluelist=(.25 .50 .75 1.0)));
if (PLOTHW=1 AND PLOTEP=0)
bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / modelname
="Survival" fillattrs=GRAPHCONFIDENCE name="HW" legendlabel=
LABELHW;
endif;
if (PLOTHW=0 AND PLOTEP=1)
bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / modelname
="Survival" fillattrs=GRAPHCONFIDENCE name="EP" legendlabel=
LABELEP;
endif;
if (PLOTHW=1 AND PLOTEP=1)
bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / modelname
="Survival" fillattrs=GRAPHDATA1 datatransparency=.55 name="HW"
legendlabel=LABELHW;
bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / modelname=
"Survival" fillattrs=GRAPHDATA2 datatransparency=.55 name="EP"
legendlabel=LABELEP;
endif;
if (PLOTCL=1)
if (PLOTHW=1 OR PLOTEP=1)
bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
modelname="Survival" display=(outline) outlineattrs=
GRAPHPREDICTIONLIMITS name="CL" legendlabel=LABELCL;
else
bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
modelname="Survival" fillattrs=GRAPHCONFIDENCE name="CL"
legendlabel=LABELCL;
endif;
endif;
stepplot y=SURVIVAL x=TIME / name="Survival" rolename=(_tip1=
ATRISK _tip2=EVENT) tip=(y x Time _tip1 _tip2) legendlabel=
"Survival";
if (PLOTCENSORED=1)
scatterplot y=CENSORED x=TIME / markerattrs=(symbol=plus) name=
"Censored" legendlabel="Censored";
endif;
if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)
discretelegend "Censored" "CL" "HW" "EP" / location=outside
halign=center;
else
if (PLOTCENSORED=1)
discretelegend "Censored" / location=inside autoalign=(topright
bottomleft);
endif;
endif;
if (PLOTATRISK=1)
innermargin / align=bottom;
blockplot x=TATRISK block=ATRISK / repeatedvalues=true display=
(values) valuehalign=start valuefitpolicy=truncate
labelposition=left labelattrs=GRAPHVALUETEXT valueattrs=
GRAPHDATATEXT (size=7pt) includemissingclass=false;
endinnermargin;
endif;
endlayout;
else
entrytitle "Product-Limit Survival Estimates";
if (EXISTS(SECONDTITLE))
entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
endif;
/* Original syntax */
* layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05 linearopts
=(viewmax=MAXTIME)) yaxisopts=(label="Survival Probability"
shortlabel="Survival" linearopts=(viewmin=0 viewmax=1
tickvaluelist=(0 .2 .4 .6 .8 1.0)));
/* Modified syntax - modify axes */
layout overlay /
xaxisopts=(shortlabel=XNAME offsetmin=.05
linearopts=(viewmax=80 tickvaluelist=(0 10 20 30 40 50 60 70 80)))
yaxisopts=(label="Survival Probs" shortlabel="Survival"
linearopts=(viewmin=.25 viewmax=1 tickvaluelist=(.25 .50 .75 1.0)));
if (PLOTHW)
bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / group=
STRATUM index=STRATUMNUM modelname="Survival" datatransparency=
Transparency;
endif;
if (PLOTEP)
bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / group=
STRATUM index=STRATUMNUM modelname="Survival" datatransparency=
Transparency;
endif;
if (PLOTCL)
if (PLOTBAND)
bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / group=
STRATUM index=STRATUMNUM modelname="Survival" display=(outline);
else
bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / group=
STRATUM index=STRATUMNUM modelname="Survival" datatransparency=
Transparency;
endif;
endif;
stepplot y=SURVIVAL x=TIME / group=STRATUM index=STRATUMNUM name=
"Survival" rolename=(_tip1=ATRISK _tip2=EVENT) tip=(y x Time
_tip1 _tip2);
if (PLOTCENSORED)
scatterplot y=CENSORED x=TIME / group=STRATUM index=STRATUMNUM
markerattrs=(symbol=plus);
endif;
if (PLOTATRISK)
innermargin / align=bottom;
blockplot x=TATRISK block=ATRISK / class=CLASSATRISK
repeatedvalues=true display=(label values) valuehalign=start
valuefitpolicy=truncate labelposition=left labelattrs=
GRAPHVALUETEXT valueattrs=GRAPHDATATEXT (size=7pt)
includemissingclass=false;
endinnermargin;
endif;
DiscreteLegend "Survival" / title=GROUPNAME location=outside;
if (PLOTCENSORED)
if (PLOTTEST)
layout gridded / rows=2 autoalign=(TOPRIGHT BOTTOMLEFT TOP
BOTTOM) border=true BackgroundColor=GraphWalls:Color Opaque=
true;
entry "+ Censored";
if (PVALUE < .0001)
entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
else
entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
endif;
endlayout;
else
layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT TOP
BOTTOM) border=true BackgroundColor=GraphWalls:Color Opaque=
true;
entry "+ Censored";
endlayout;
endif;
else
if (PLOTTEST)
layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT TOP
BOTTOM) border=true BackgroundColor=GraphWalls:Color Opaque=
true;
if (PVALUE < .0001)
entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
else
entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
endif;
endlayout;
endif;
endif;
endlayout;
endif;
endgraph;
end;
run;
/********************/
/* LIFETEST example */
/********************/
data myeloma;
input time vstatus logbun hgb platelet age logwbc frac
logpbm protein scalc;
datalines;
1.25 1 2.2175 9.4 1 67 3.6628 1 1.9542 12 10
1.25 1 1.9395 12.0 1 38 3.9868 1 1.9542 20 18
2.00 1 1.5185 9.8 1 81 3.8751 1 2.0000 2 15
2.00 1 1.7482 11.3 0 75 3.8062 1 1.2553 0 12
2.00 1 1.3010 5.1 0 57 3.7243 1 2.0000 3 9
3.00 1 1.5441 6.7 1 46 4.4757 0 1.9345 12 10
5.00 1 2.2355 10.1 1 50 4.9542 1 1.6628 4 9
5.00 1 1.6812 6.5 1 74 3.7324 0 1.7324 5 9
13.00 0 1.6628 4.9 0 71 3.6435 0 1.7924 0 9
16.00 0 1.1461 13.0 1 55 3.8573 0 0.9031 0 9
19.00 0 1.3222 13.0 1 59 3.7709 1 2.0000 1 10
19.00 0 1.3222 10.8 1 69 3.8808 1 1.5185 0 10
28.00 0 1.2304 7.3 1 82 3.7482 1 1.6721 0 9
41.00 0 1.7559 12.8 1 72 3.7243 1 1.4472 1 9
53.00 0 1.1139 12.0 1 66 3.6128 1 2.0000 1 11
57.00 0 1.2553 12.5 1 66 3.9685 0 1.9542 0 11
77.00 0 1.0792 14.0 1 60 3.6812 0 0.9542 0 12
;
run;
ods graphics / reset noborder width=600px height=400px;
ods listing close;
ods html file='lifetest.html' path='.' style=listing;
ods select SurvivalPlot;
proc lifetest data=myeloma plots=survival;
strata frac;
time time*vstatus(0);
run;
quit;
ods html close;
ods listing;
ods graphics off;
/* Delete the custom template in order to use the original */
/* template the next time PROC LIFETEST is run. */
proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival;
run;
quit;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> LIFETEST |
Date Modified: | 2011-08-10 11:49:21 |
Date Created: | 2011-08-04 10:41:18 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/STAT | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |