turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Display BY group names in survival plots in PROC L...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-27-2014 08:24 PM

Dear Community,

My data set has an indicator variable named "BY_GROUPS" that shows the names of 2 groups: A and B. I need to plot 2 different survival functions in PROC LIFETEST based on these 2 groups. (Note that I am NOT trying to plot the 2 groups as 2 strata on the same survival plot.)

I can do this by running PROC LIFETEST with the BY statement. However, I can't figure out how to display the names "A" and "B" in the plot. The documentation and online resources don't reveal an answer.

Could you please help?

My sample code is below.

Thanks,

Eric

_________________________________________________________________________________

PROC LIFETEST

data = my_survival_data

method = KM

notable

plots = survival

(

CB

atrisk

);

time survival_time * censor_variable(1);

strata strata_group;

by BY_GROUP;

run;

Accepted Solutions

Solution

11-10-2014
03:08 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-10-2014 03:08 PM

Hi Reeza,

I have SAS 9.3.

I found a simple solution. Instead of using the "BY" statement in PROC LIFETEST to get the plots for the 2 groups, I used 2 separate PROC LIFETEST procedures to get the 2 plots. I was then able to specify the group in my "TITLE" statements. I used the "WHERE =" option to select the group that I wanted after specifying the data.

It's not very elegant, but it works.

PROC LIFETEST

data = my_survival_data

(

where = (

group = 'A'

)

)

method = KM

notable

plots = survival

(

CB

atrisk

);

time survival_time * censor_variable(1);

strata strata_group;

title 'Survival Plot for Group A';

run;

PROC LIFETEST

data = my_survival_data

(

where = (

group = 'B'

)

)

method = KM

notable

plots = survival

(

CB

atrisk

);

time survival_time * censor_variable(1);

strata strata_group;

title 'Survival Plot for Group B';

run;

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EricCai

10-27-2014 10:55 PM

What version of SAS are you on?

I know you can definitely do it by modifying the templates, if you have SAS 9.4 you may have an odstitle option but I'm not sure.

Here's instructions on how to modify the title by modifying the template.

Solution

11-10-2014
03:08 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-10-2014 03:08 PM

Hi Reeza,

I have SAS 9.3.

I found a simple solution. Instead of using the "BY" statement in PROC LIFETEST to get the plots for the 2 groups, I used 2 separate PROC LIFETEST procedures to get the 2 plots. I was then able to specify the group in my "TITLE" statements. I used the "WHERE =" option to select the group that I wanted after specifying the data.

It's not very elegant, but it works.

PROC LIFETEST

data = my_survival_data

(

where = (

group = 'A'

)

)

method = KM

notable

plots = survival

(

CB

atrisk

);

time survival_time * censor_variable(1);

strata strata_group;

title 'Survival Plot for Group A';

run;

PROC LIFETEST

data = my_survival_data

(

where = (

group = 'B'

)

)

method = KM

notable

plots = survival

(

CB

atrisk

);

time survival_time * censor_variable(1);

strata strata_group;

title 'Survival Plot for Group B';

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to EricCai

11-11-2014 01:52 PM

I assumed you were trying to change the default title. If title statements work try using the #byval(group) instead.

PROC LIFETEST

data = my_survival_data

method = KM

notable

plots = survival

(

CB

atrisk

);

by group

time survival_time * censor_variable(1);

strata strata_group;

title 'Survival Plot for Group #byval(group)';

run;