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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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