- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;