Data visualization with SAS programming

Outputting KM curve with transparent background

Reply
Occasional Contributor
Posts: 17

Outputting KM curve with transparent background

Dear all,

I am trying to ouput a KM curve using proc lifetest, but with with transparent background. This way, I can overlay the image over another JPEG image and see if the curves overlap. At the moment, the JPEG image appears with white, non-transparent background. I wish to keep everything the same (curve colors, etc) except the the background.

 

ods rtf file="&outputloc\test.rtf";
proc lifetest data=test method=KM
plots=survival(atrisk=0 to 30 by 3) timelist=0 to 30 by 3;
time os_m*censors(0);
strata treat;
title1 'Kaplan-Meier Plot for OS';
label os_m="Months";
where itt=1;
run;
ods rtf close;

 

 

Thank you,

MK

 

Occasional Contributor
Posts: 17

Re: Outputting KM curve with transparent background

PS: These need to go in a power point slide deck.

Grand Advisor
Posts: 17,423

Re: Outputting KM curve with transparent background

I'm assuming you're not using SAS 9.4 since you're not using ODS PPT?

 

Anyways, here's a starter on customizing survival plots. It's not as easy as you'd like, unfortunately. 

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_kaplan_toc.h...

SAS Super FREQ
Posts: 1,081

Re: Outputting KM curve with transparent background

With SAS 9.40M3, GTL supports output with transparent background.  You will also have to make the wall transparent.

See OPAQUE option in BEGINGRAPH.

Occasional Contributor
Posts: 17

Re: Outputting KM curve with transparent background

I am using SAS 9.4. Do you have a sample code that outputs the KM graph with transparent background?

SAS Super FREQ
Posts: 1,081

Re: Outputting KM curve with transparent background

If you have SAS 9.40M3 (M3 is important), you can do one of the following:

 

Change the PROC Lifetest template.

  1. Find the name of the template using ODS TRACE on;
  2. Then update the template to make the background and wall transparent.
  3. Rerun your proc lifetest program.

 

Or, run the lifetest procedure and get the data saved to a sas data set using ODS OUTPUT.

  1. Run your own SGPLOT program to create the Survival plot using program below.
  2. Note the NOOPAQUE and NOWALL options on the SGPLOT procedure statement.

 

/*--Get survival plot data from LIFETEST procedure--*/
ods graphics on;
ods output Survivalplot=SurvivalPlotData;
proc lifetest data=sashelp.BMT plots=survival(atrisk=0 to 2500 by 500);
time T * Status(0);
strata Group / test=logrank adjust=sidak;
run;

 

/*--Survival Plot with outer Risk Table using AxisTable Transparent--*/
ods html close;
ods graphics / reset imagename='Survival Plot_SG_V94_Trans';
title 'Product-Limit Survival Estimates';
title2 h=0.8 'With Number of AML Subjects at Risk';
proc sgplot data=SurvivalPlotData noopaque nowall;
step x=time y=survival / group=stratum lineattrs=(pattern=solid) name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
xaxistable atrisk / x=tatrisk location=outside class=stratum colorgroup=stratum;
keylegend 'c' / location=inside position=topright;
keylegend 's';
run;

 

Occasional Contributor
Posts: 17

Re: Outputting KM curve with transparent background

Thank you 

 

SAS Super FREQ
Posts: 1,081

Re: Outputting KM curve with transparent background

I believe you (or your company) can upgrade to a new maintenance release.

Contact contracts@sas.com, or, call our customer service line 919-677-8003.

 

Ask a Question
Discussion stats
  • 7 replies
  • 150 views
  • 0 likes
  • 3 in conversation