BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EricCai
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
EricCai
Calcite | Level 5

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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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.

SAS/STAT(R) 9.2 User's Guide, Second Edition

EricCai
Calcite | Level 5

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;

Reeza
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1849 views
  • 3 likes
  • 2 in conversation