BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User
Use ODS TRACE to see the table/graph names to ensure your ODS statement is correct.

Also what does 'it doesn't work' mean? That could be anything from a syntax error to SAS crashing.
ANKH1
Pyrite | Level 9

There was no output.

ANKH1
Pyrite | Level 9

I used the following:

proc lifetest data=sample plots=survival(f)
outsurv=survival_data timelist=(0 to 200 by 12) reduceout;
strata group;
time time2event*censor(1);
run;

I get the dataset to be use in proc sgplot but I am not sure what to put in the Y axis. The examples I've seen are with "Survival" not like the graph for cumulative incidence. I tried to use Failure but it says that the variable does not exist.

Reeza
Super User
That outputs the raw data, you'll have to re-do the calculations. You were on the right track trying to get the plot data instead, but you have the wrong graph name - it's a failure plot not survival plot. Use ODS TRACE, check the log to get the correct ODS name.

https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html
Reeza
Super User
Why? What did the log say?
ANKH1
Pyrite | Level 9

with this code:

proc sgplot data=survival_data;
step x=time2event y=survival/group=stratum name="Percentage of patients reporting the first event";
xaxis values=(0 to 24 by 2) valueshint label="Time to event (Months)";
yaxis offsetmin=0.02 min=0 offsetmax=0.1 max=1.0 label="Percentage of patients reporting the First Event";
run;

I get this output:

km2.jpg

Reeza
Super User
Correct, that is the survival plot, not the failure plot. The plots=survival(f) -> the f option requests failure which is what you're looking for instead (IMO).
ANKH1
Pyrite | Level 9

Yes, you are right, the failure plot is what we need. I used ODS TRACE ON as you advised and got the right name:

 

ods trace on;
ods output failureplot=sp;
proc lifetest data=sample plots=survival(f)
outsurv=survival_data timelist=(0 to 24 by 2) reduceout;
strata group;
time time2event*censor(1);
run;

proc sgplot data=sp;
step x=time y=_1_survival_/group=stratum name="Percentage of patients reporting the first event";
xaxis values=(0 to 24 by 2) valueshint label="Time to event (Months)";
yaxis offsetmin=0.02 min=0 offsetmax=0.1 max=1.0 label="Percentage of patients reporting the First Event";
run;

and got this:

 

km3.jpg

Looks ok right? I used variable _1_survival_ instead of survival. I have a question if we want to show the censored, how will you add it? 

ANKH1
Pyrite | Level 9

Thanks for sharing. What is the difference between these two statements?:

scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;

 

And since this is a failure plot, should I use _1_censored_ instead of censored?

 

proc sgplot data=sp;
step x=time y=_1_survival_/group=stratum name="Percentage of patients reporting the first event";
xaxis values=(0 to 24 by 2) valueshint label="Time to event (Months)";
yaxis offsetmin=0.02 min=0 offsetmax=0.1 max=1.0 label="Percentage of patients reporting the First Event";
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) name='censored';
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) GROUP=stratum;
run;

This is the figure.

km4.jpg

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 24 replies
  • 3858 views
  • 0 likes
  • 2 in conversation