BookmarkSubscribeRSS Feed
Sikcion
Fluorite | Level 6

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:

Screenshot 2023-12-31 at 4.20.46 AM.png

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!

 

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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".

WarrenKuhfeld
Ammonite | Level 13

https://support.sas.com/documentation/onlinedoc/stat/151/kaplan.pdf

 

If you are customizing the Kaplan-Meier plot, you should know about this chapter.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 763 views
  • 6 likes
  • 3 in conversation