BookmarkSubscribeRSS Feed
Jest
Obsidian | Level 7

why is it not straightforward to change the axis in a survival plot in proc lifetest?

 

I have been trying to change the x-axis and it doesn't seem to take...any ideas?

 

%let xOptions = label="Time to Event (months)"
linearopts=(viewmin=0 viewmax=12
tickvaluelist=(0 2 4 6 8 10 12));

proc lifetest data=Work.Work atrisk plots=survival(atrisk cb) outs=out;
strata type;
time visit*status(0);
run;

13 REPLIES 13
ballardw
Super User

Why? Probably because most of the graphics from analysis procedures are not intended to produce publication ready graphs but to provide information for analysis.

 

You have to set the option and then use the macros

%providesurvivalmacros

%compilesurvivaltemplates

AFTER you set the option macro variable.

You have to re-execute the macros each time to apply the values.

Jest
Obsidian | Level 7

tried that. It didn't work...

 

%ProvideSurvivalMacros;
%let xOptions = label="Time to Event (months)"
linearopts=(viewmin=0 viewmax=12)
tickvaluelist=(0 2 4 6 8 10 12));
%CompileSurvivalMacros;
proc lifetest data=Work.Work atrisk plots=survival(atrisk cb) outs=out;
strata type;
time visit*status(0);
run;

 

am I missing something?

ballardw
Super User

You might try posting the log if there are any messages.

Or some example data that will duplicate the (non-)behavior.

Jest
Obsidian | Level 7

This is the error from the log:

 

12018 %CompileSurvivalMacros;
-
180
WARNING: Apparent invocation of macro COMPILESURVIVALMACROS not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Many thanks!!

Reeza
Super User

What version of SAS are you using?

ballardw
Super User

Have you gone to http://support.sas.com/documentation/onlinedoc/stat/ex_code/141/templft.html

and downloaded the source file for the macros? Is the source file named  ProvideSurvivalMacros.SAS and in your SASAUTOS path?

Jest
Obsidian | Level 7

No, I haven't done that part as I assumed it is already built in in SAS.

Excuse my ignorance but what is the best way of downloading the template?

 

Also, I have been reading the following instrucyions:

https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_templt_a000...

 

How does one use the layout overlay statement with the proc lifetest..

 

I really think this should be easier, as in other programs like STATA it is much easier...

 

any ideas?

 

 

ballardw
Super User

@Jest wrote:

No, I haven't done that part as I assumed it is already built in in SAS.

Excuse my ignorance but what is the best way of downloading the template?

 


I don't know if it is "best" but I copied and pasted the text from the code section into an editor and saved it.

 

You will really have to clarify what you mean by "use layout overlay". The ProvideSurvivalMacros uses Layout overlay in 5 different locations.

 

If you investigate the templates associated with Proc Lifereg there are over 50 templates associated. Depending on what I want to display I generally dump data to output sets and build graphs from scratch (or Graphics Designer) instead of attempting to create pulication quality graphics from analysis templates.

Peter_C
Rhodochrosite | Level 12
In one of the macros at the link provided above by @ballardw, I was very surprised to see:
%scan(2,2-&outside)
Could someone explain what this does when &outside has value=0
?
ballardw
Super User

@Peter_C wrote:
In one of the macros at the link provided above by @ballardw, I was very surprised to see:
%scan(2,2-&outside)
Could someone explain what this does when &outside has value=0
?

Since the value scanned would be a single word and items more than 1 requested would yield a blank as the macro processor does the arithmetic and 2-0=2, so scans for the second "word".

See the log after running

 

%let k =%scan(1,2-0);

%put &k;

%let k =%scan(1 2,2-0);

%put &k;

 

Peter_C
Rhodochrosite | Level 12
%scan(2,2-&outside)Seems a complicated way to produce 2 or nothing
ballardw
Super User

@Peter_C wrote:
%scan(2,2-&outside)Seems a complicated way to produce 2 or nothing

Agreed. Certainly more than a tad obtuse.

 

I didn't read all of that code so I'm not sure if there are cases where &outside could be blank or a non-numeric appearing value which would be an error

Peter_C
Rhodochrosite | Level 12
Usually &outside is used in a boolean test. Its value is fixed as either 0 or 1.It is used in constructing proc template code - I do not think the %do loop provides much benefit over a repeat of the base code being generated with the few, minor variations 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 13 replies
  • 2116 views
  • 2 likes
  • 4 in conversation