Hi guys! I'm creating one KM-Plot and have some questions;
Here is my code:
ods output Survivalplot=SurvivalPlotData;
ods graphics on;
proc lifetest data=adtte1 plots=survival(atrisk=0 to 15 by 3);
time aval * cnsr(1);
strata trtp/ test=logrank adjust=sidak; /
run;
/**2)Using Proc Sgplot**/;
ods listing style = htmlblue gpath="/home/u62957101/sasuser.v94/Project2C/output";
ods graphics / reset width=5in height=3in imagename="Survival_Plot_SG" ;
title1 j=c "Kaplan Meier Curves for Progression Free Survival by Treatment Arm in Second";
title2 j=c"Remission";
title3 j=c"Randomized Subjects with 2nd Remission";
footnote1 " ";
footnote2 j=l h=6pt "Study PRJ5457C" j=r "Page 1 of 1";
footnote3 j=l h=6pt "TLG Specifications, Version 9.4";
/**Creation of KM Plot**/;
proc sgplot data=SurvivalPlotData noborder;
step x=time y=survival / group=stratum name="s";
scatter x=time y=censored/ markerattrs=(symbol=plus ) GROUP=stratum;
scatter x=time y=censored / markerattrs=(symbol=plus) name="c";
xaxistable atrisk/ x=tatrisk class=stratum colorgroup=stratum
valueattrs=(weight=bold);
keylegend "s" / linelength=20;
keylegend "c" / location = inside position=topright;
run;
title;
My output:
I have 2 questions:
1)How can I change the cmp-135 group line to red color and placebo group to blue color?
2)I utilized the plots=survival(atrisk=0 to 15 by 3) to hope my X line cutoff be like "0,3,6,9,12,15" , while it still are "0,2.5,5,..15);
Thanks for your help!
Hi @Sikcion,
1) To swap the colors, insert a STYLEATTRS statement into your PROC SGPLOT step:
styleattrs datacontrastcolors=(cxA23A2E cx445694);
(I took the hexadecimal RGB color values that are specified for 'gcdata2' and 'gcdata1' in Sashelp.Tmplmst\Styles\Statistical.)
2) For the desired tick marks insert an XAXIS statement into your PROC SGPLOT step:
xaxis values=(0 to 15 by 3) label='Analysis Value';
Note that without the LABEL= option I got a default x-axis label of "Failure or Censoring Time". So you may also need a YAXIS statement to replace the default y-axis label "Survival Probability".
https://support.sas.com/documentation/onlinedoc/stat/151/kaplan.pdf
If you are customizing the Kaplan-Meier plot, you should know about this chapter.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.