BookmarkSubscribeRSS Feed
Kels123
Quartz | Level 8

Hi,

 

I need to save my Kaplan-Meier curves in a format other that will be more easily editable for a journal. Right now, SAS is only allowing me to save the images as .png or .bmp files. Is there a way I can just add a outputfmt= statement to my code to output my curves as .ai, .eps, or .pdf files? Here is the code I am using below. Thank you in advance!

 

data _null_;

   %let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/142;

   infile "http:&url/templft.html" device=url;

 

   file 'macros.tmp';

   retain pre 0;

   input;

   _infile_ = tranwrd(_infile_, '&', '&');

   _infile_ = tranwrd(_infile_, '&lt;' , '<');

   if index(_infile_, '</pre>') then pre = 0;

   if pre then put _infile_;

   if index(_infile_, '<pre>')  then pre = 1;

run;

 

%inc 'macros.tmp' / nosource;

 

* Modify the template;

%ProvideSurvivalMacros

%let TitleText0 = "Kaplan-Meier Plot: Probability of death, stratified by CD4 count at time of HIV diagnosis";

%let yOptions = label="Survival Probability"

                linearopts=(viewmin=0.7 viewmax=1 tickvaluelist=(0.7 0.8 0.9 1.0));

%let xOptions = label="Time (days since release)" ;

%let GraphOpts = DataContrastColors=(green red blue)

DataColors=(green red blue);

/*%let TitleText1 = &titletext0 "CD4 count at diagnosis " STRATUMID;*/

%CompileSurvivalTemplates

 

*KM stratified by AIDS STAGE**************************************************************;

proc format ;

invalue CD4_atdiagnosiscat '>=500 cells/µL' = 1 '200-499 cells/µL' = 2 '<200 cells/µL' = 3;

value CD4_atdiagnosisfmt 1 = '>=500 cells/µL' 2 = '200-499 cells/µL' 3 = '<200 cells/µL';

run;

data tempCD4(drop=g);

set CLEAN.databasesurv3(rename=(CD4_atdiagnosis=g));

CD4_atdiagnosis = input(g, CD4_atdiagnosiscat.);

run;

* Analysis;

ods graphics on;

proc lifetest data=work.tempCD4 method=km atrisk

    plots=(S(test nocensor atrisk(maxlen=16 outside(0.12))=0 to 3000 by 500) /*method=km MAXTIME= 3000 intervals=(0 to 3000 by 500)*/);

    time time*EVENT_ANYDEATH(0);

    strata CD4_atdiagnosis / order=internal adjust=sidak test=logrank ;

label CD4_atdiagnosis = "CD4 count at diagnosis";

    format CD4_atdiagnosis CD4_atdiagnosisfmt.;

run;

ods graphics off;

 

8 REPLIES 8
pau13rown
Lapis Lazuli | Level 10

don't journals typically demand tiff?

Kels123
Quartz | Level 8

Here is what we were instructed: "For any statistical images you should provide editable vector files (ie, the original artwork generated by the statistical package used to make the image); our preferred formats for these files are .ai, .eps, or .pdf." Do you think a .png file would be acceptable based on these guidelines?

 

I was able to figure out how to generate a pdf file using the bolded statement. However, when looking at the PDF files produced, for some reason SAS is making 2 of the 3 the K-M lines formatted as dotted instead of simple solid lines. This is not how they show up in SAS, which is confusing me and I am not sure how to tweak the code to fix this.

 

ods graphics on / OUTPUTFMT=pdf imagename="K-M Curve CD4";

ods listing gpath="J:\Kelsey data created 03.16.2016\Kelsey's mortality folder";

proc lifetest data=work.tempCD4 method=km atrisk

    plots=(S(test nocensor atrisk(maxlen=16 outside(0.12))=0 to 3000 by 500) /*method=km MAXTIME= 3000 intervals=(0 to 3000 by 500)*/);

    time time*EVENT_ANYDEATH(0);

    strata CD4_atdiagnosis / order=internal adjust=sidak test=logrank ;

label CD4_atdiagnosis = "CD4 count at diagnosis";

    format CD4_atdiagnosis CD4_atdiagnosisfmt.;

run;

ods graphics off;

pau13rown
Lapis Lazuli | Level 10

ok, i've been there before. I think i created tiff and then used gimp to convert to eps or pdf. Install gimp 2 then search google 'convert tiff to eps using gimp', something like that

 

edit: http://gimpchat.com/viewtopic.php?f=8&t=8245

Reeza
Super User

For PDF you can also use ODS PDF. 

 

Cynthia_sas
SAS Super FREQ
Hi, the ODS GRAPHICS statement supports an imagefmt= option. But, the value has to be supported by the destination you're using. I suggest you look at the documentation for the ODS GRAPHICS statement and the imagefmt option.

Cynthia
Kels123
Quartz | Level 8

I put this code together using outputfmt (also tried imagefmt) but unfortunately PDF is not supported by the destination I am trying to save it to:

 

ods graphics on / OUTPUTFMT=pdf imagename="K-M Curve CD4";

ods listing gpath="C:\Users\Kelsey\Desktop\SURVIVAL CURVES - PDF ATTEMPTS" ;

proc lifetest data=work.tempCD4 method=km atrisk

    plots=(S(test nocensor atrisk (maxlen=16 outside(0.12))=0 to 3000 by 500) /*method=km MAXTIME= 3000 intervals=(0 to 3000 by 500)*/);

    time time*EVENT_ANYDEATH(0);

    strata CD4_atdiagnosis / order=internal adjust=sidak test=logrank ;

label CD4_atdiagnosis = "CD4 count at diagnosis";

    format CD4_atdiagnosis CD4_atdiagnosisfmt.;

run;

ods graphics off;

 

 

Any additional suggestions for how to get around this? I find it hard to believe that there is no standardized way of saving a survival curve as a PDF directly from SAS.

 

Thank you in advance.

Cynthia_sas
SAS Super FREQ

Hi:

  As @Reeza already suggested, you CAN save ALL your output in PDF format by using ODS PDF. For that you don't need imagefmt or outputfmt options.

 

 Cynthia

ChrisHemedinger
Community Manager

You might also want to tweak the resolution for publication -- see tips from @Jay54 on this topic.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 8 replies
  • 3481 views
  • 0 likes
  • 5 in conversation