Hi all,
I am struggling with changing Y-axis for my KM curves. I would love to get help from you all. I am looking for generating Survival curves for time to cancer (not death), cumulative incidence graphs and Hazard Ratio graphs. I got the following survival curve, but not sure if I did the right way. Also for Hazard Ratio curve, I want to convert the axes (instead of 0.001, 0.002..etc. I want it as 0, 1/1000, 2/1000 ...etc. or something simple like 0 , 1, 2, 3, 4, etc. and a footnote saying the Y axes is per 1000).
Name of the dataset: AP_PDAC
My outcome is pancreatic cancer: PDAC (0/1)
Grouping Variable: AP (0/1)
Time variable: time from risk factor AP to PDAC diagnosis date : Dur_Yrs (in years).
Thank you so much!
proc lifetest data=AP_PDAC plots=(survival(atrisk) logsurv);
time Dur_Yrs*PDAC(0);
strata AP;
run;
Hi Reeza,
I used the following macro for changing the Y-axis for my survival curves. However, I did not get the output. Will this work for a SAS enterprise guide on remote desktop login to a research server platform?
My outcome is cancer: PDAC (0/1)
Grouping Variable: Treat (1/2/3/4)
Time variable: time from risk factor Treat to cancer diagnosis date : Dur_Yrs (in years). I would like to get survival curves and adjust the Y-axis. The grouping variable Treat = 1 has about 8 million records, Treat =2 has 50,000 records, Treat = 3 has 20,000 records and Treat =4 has 15,000 records.
Thank you so much for your help!
SM
%ProvideSurvivalMacros
%let yOptions = label="Survival"
linearopts=(viewmin=0.8 viewmax=1
tickvaluelist=(0 .2 .4 .6 .8 1.0));
%CompileSurvivalTemplates
proc lifetest data=PDAC.Year2Over plots=survival;
time Dur_Yrs * PDAC(0);
strata Treat;
run;
You can check what you have licensed in SAS using:
proc setinit; run;
And what's installed on your system using:
proc product_status; run;
The output will be in the log.
@sms1891 wrote:
Hi Reeza,
I used the following macro for changing the Y-axis for my survival curves. However, I did not get the output. Will this work for a SAS enterprise guide on remote desktop login to a research server platform?
My outcome is cancer: PDAC (0/1)
Grouping Variable: Treat (1/2/3/4)
Time variable: time from risk factor Treat to cancer diagnosis date : Dur_Yrs (in years). I would like to get survival curves and adjust the Y-axis. The grouping variable Treat = 1 has about 8 million records, Treat =2 has 50,000 records, Treat = 3 has 20,000 records and Treat =4 has 15,000 records.
Thank you so much for your help!
SM
%ProvideSurvivalMacros %let yOptions = label="Survival" linearopts=(viewmin=0.8 viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)); %CompileSurvivalTemplates proc lifetest data=PDAC.Year2Over plots=survival; time Dur_Yrs * PDAC(0); strata Treat; run;
Reeza,
I have SAS 9.04, Operating system LIN X64. I uses SAs enterprise guide 7.1. I tried running a different proc template before this code. Do you think what would affect the current code?
Thanks,
SM
I am not familiar with proc template, so sorry for my ignorance. I am not sure how to backup a template. One of my colleague gave me a proc template code and asked me to run it before the proc lifetest so I ran it. (see the attached code) I did not make any modifications as I cant understand what it is for.
proc template;
source stat.lifetest.graphics.productlimitsurvival;
define statgraph Stat.Lifetest.Graphics.Productlimitsurvival;
dynamic NStrata xName plotAtRisk plotCensored plotCL plotHW plotEP labelCL labelHW labelEP maxTime xtickVals xtickValFitPol rowWeights method StratumID classAtRisk plotTest GroupName Transparency
SecondTitle TestName pValue _byline_ _bytitle_ _byfootnote_;
BeginGraph;
if (NSTRATA=1)
if (EXISTS(STRATUMID))
entrytitle " Survival Estimate" " for " STRATUMID;
else
entrytitle " Survival Estimate" " for " STRATUMID;
endif;
if (PLOTATRISK=1)
entrytitle "With Number of Patients at Risk" / textattrs=GRAPHVALUETEXT;******THIS WAS MODIFIED from subjects to patients;
endif;
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)));
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) tiplabel=(_tip1="Number at Risk" _tip2="Observed Events") tip=(x y _tip1 _tip2) legendlabel="Survival";
if (PLOTCENSORED=1)
scatterplot y=CENSORED x=TIME / markerattrs=(symbol=plus) tiplabel=(y="Survival Probability") 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;
axistable x=TATRISK value=ATRISK / display=(label) valueattrs=(size=7pt);
endinnermargin;
endif;
endlayout;
else
entrytitle "Kaplan Meier Curves for All cause mortality" ;
if (PLOTATRISK=1)
entrytitle "With Number of Participants at Risk" / textattrs=GRAPHVALUETEXT;******THIS WAS MODIFIED from subjects to patients;
endif;
* if (EXISTS(SECONDTITLE))
entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
*endif;
layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05 linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS tickvaluefitpolicy=XTICKVALFITPOL)) yaxisopts=(label="Survival Probability"
shortlabel="Survival" linearopts=(viewmin=.6 viewmax=1 tickvaluelist=(.6 .7 .8 .9 1)));
if (PLOTHW=1)
bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / group=STRATUM index=STRATUMNUM modelname="Survival" datatransparency=Transparency;
endif;
if (PLOTEP=1)
bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / group=STRATUM index=STRATUMNUM modelname="Survival" datatransparency=Transparency;
endif;
if (PLOTCL=1)
if (PLOTHW=1 OR PLOTEP=1)
bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / group=STRATUM index=STRATUMNUM modelname="Survival" display=(outline) outlineattrs=(pattern=ShortDash);
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) tiplabel=(_tip1="Number at Risk" _tip2="Observed Events") tip=(x y _tip1
_tip2);
if (PLOTCENSORED=1)
scatterplot y=CENSORED x=TIME / group=STRATUM index=STRATUMNUM tiplabel=(y="Survival Probability") markerattrs=(symbol=plus);
endif;
if (PLOTATRISK=1)
innermargin / align=bottom;
axistable x=TATRISK value=ATRISK / display=(label) valueattrs=(size=7pt) class=CLASSATRISK colorgroup=CLASSATRISK;
endinnermargin;
endif;
DiscreteLegend "Survival" / title=GROUPNAME location=outside;
if (PLOTCENSORED=1)
if (PLOTTEST=1)
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=1)
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;
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
EndGraph;
end;
run;
My SAS is 9.04.01M5P091317
Hi Reeza,
Did you get my reply yesterday? Would love to get your feedback.
Thanks,
Sat
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.