BookmarkSubscribeRSS Feed
KPCklebspn
Obsidian | Level 7

Hi everyone, I want to modify the y axis on my KM curve (failure). I found the macro online, but when I run below I get an error (attached) in the macro. Is there something I need to put before this? I'm really having a hard time with how macros work

 

%ProvideSurvivalMacros
%let yOptions = label="Failure"linearopts=(viewmin=0 viewmax=0.2 tickvaluelist=(0 .05 .1 .15 .2));
%CompileSurvivalTemplates

 

proc lifetest data = ammihc1 plots=survival(failure);
time survtime*outcome(0); run;

6 REPLIES 6
Rick_SAS
SAS Super FREQ

Did you actually execute the source code that defines the macros?

 

The SAS/STAT documentation provides instructions about how to save the macro to a text file.

You can then %INCLUDE the contents of the text file, which will define several macros, including the ones you mention.

 

Also, put a space before the LINEAROPTS keyword.

 

KPCklebspn
Obsidian | Level 7

Hi Rick, thanks so much for the reply...pardon my ignorance but I am not super familiar with macros. What does "executing the source code that defines the macros" mean/how do I do that? Thank you

Rick_SAS
SAS Super FREQ

I provided a link to the documentation. In that example, there is the line

%inc 'macros.tmp' / nosource;

When you run that statement (or one like it), SAS runs the contents of the 'macros.tmp' file, which contains the definition of the macros and enables SAS to know what code to run when you execute the line

%ProvideSurvivalMacros

 

At some point, you downloaded the macro definitions and stored them in a file. I think you need to %INCLUDE that file before you run the example. If the file is "C:/temp/MySASMacro.txt" you would execute

%include "C:/temp/MySASMacro.txt" / nosource;

KPCklebspn
Obsidian | Level 7

Ok, so I've run this code:

 

data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/151;
infile "http:&url/templft.html" device=url;

 

file '/folders/myfolders/CPE/AMMI2019 reanalysis/KM macro.txt'; /*THIS LINE HAS MY FILE*/
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 "/folders/myfolders/CPE/AMMI2019 reanalysis/KM macro.txt" / nosource; /*THIS LINE HAS MY FILE*/

 

%ProvideSurvivalMacros
%let yOptions = label="Failure" linearopts=(viewmin=0 viewmax=0.2 tickvaluelist=(0 .05 .1 .15 .2));
%CompileSurvivalTemplates

 

The KM macro.txt file is a file with stuff from this link: http://support.sas.com/documentation/onlinedoc/stat/ex_code/151/templft.html

 

The output when I run the above code is the PDF attached. No error...so I think it worked? How do I actually see the graph though?

KPCklebspn
Obsidian | Level 7

Ok, so I've run this code:

 

data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/151;
infile "http:&url/templft.html" device=url;

 

file '/folders/myfolders/CPE/AMMI2019 reanalysis/KM macro.txt'; /*THIS LINE HAS MY FILE*/
retain pre 0;
input;
_infile_ = tranwrd(_infile_, '&amp;', '&');
_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 "/folders/myfolders/CPE/AMMI2019 reanalysis/KM macro.txt" / nosource; /*THIS LINE HAS MY FILE*/

 

%ProvideSurvivalMacros
%let yOptions = label="Failure" linearopts=(viewmin=0 viewmax=0.2 tickvaluelist=(0 .05 .1 .15 .2));
%CompileSurvivalTemplates

 

The KM macro.txt file is a file with stuff from this link: http://support.sas.com/documentation/onlinedoc/stat/ex_code/151/templft.html

 

The output when I run the above code is the PDF attached. No error...so I think it worked? How do I actually see the graph though?

Rick_SAS
SAS Super FREQ

Now run PROC LIFETEST. It will use the survival templates that you just compiled. The SAS/STAT documentation has many examples.

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2336 views
  • 0 likes
  • 2 in conversation