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

Hello,

 

I need to produce Kaplan-Meier results and graphics, but for the Graphic I would like to omit the curves for one or two levels of my independent variable (and do not exclude these observations from the calculations). Does anyone know how to do it ?

 

For instance, in the dataset below, I would like to exclude the level  "3" of the variable "independent_v2".

 

An example of my dataset would be:

 

data have;

input

id time1 event1 weight independent_v1 independent_v2;

datalines;

1 0 0 0.8 0 1

1 1 0 0.8 0 1

1 2 0 0.8 0 0

1 3 0 0.8 0 0

1 4 0 0.8 0 1

1 5 0 0.8 0 1

1 6 0 0.8 0 1

1 7 0 0.8 0 1

1 8 0 0.8 0 2

1 9 0 0.8 0 2

1 10 0 0.8 0 2

1 11 0 0.8 0 2

1 12 0 0.8 0 2

1 13 0 0.8 0 2

2 0 0 1.1 1 0

2 1 1 1.1 1 0

2 2 . 1.1 1 0

3 0 0 1.01 2 1

3 1 0 1.01 2 1

3 2 1 1.01 2 1

3 3 . 1.01 2 1

4 0 1 0.98 2 1

4 1 . 0.98 2 1

4 2 . 0.98 2 1

4 3 . 0.98 2 1

4 4 . 0.98 2 1

5 0 0 1.13 3 0

6 0 0 1.05 3 0

6 1 0 1.05 3 1

6 2 0 1.05 3 1

6 3 0 1.05 3 1

6 4 0 1.05 3 1

6 5 1 1.05 3 1

6 6 . 1.05 3 1

6 7 . 1.05 1 1

6 8 . 1.05 1 1

7 0 0 0.89 0 3

7 1 0 0.89 0 3

7 2 0 0.89 0 3

7 3 0 0.89 0 3

7 4 0 0.89 0 3

7 5 0 0.89 0 3

7 6 0 0.89 0 3

7 7 0 0.89 0 3

7 8 1 0.89 0 1

7 9 . 0.89 0 1

7 10 . 0.89 0 1

8 0 0 1.1 1 0

8 1 0 1.1 1 1

8 2 0 1.1 1 1

8 3 . 1.1 1 2

8 4 . 1.1 1 2

;

run;

 

So I run the survival analysis like that:

 

data _temp;

set have;

by id;

retain time;

if first.id then time=0;

if event1=1 and time=0 then do;

output;

time=1;

end;

if last.id and time=0 then output;

run;

 

proc lifetest data=_temp plots(s) graphics notable;

time time1*event1(0);

weight weight;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Full code is here, except add a WHERE option on your data to filter out the categories you don't want to include.

 

https://blogs.sas.com/content/graphicallyspeaking/2014/02/09/survival-plot/

 

proc sgplot data=SurvivalPlotData (where = (group not in (list of types to exclude)));

At Risk table is optional obviously. 

 


@MFraga wrote:

Could you give an example of how I capture the output and graph only elements I am interested in for the "independent_v2", for example?

 

Thank you!


 

View solution in original post

3 REPLIES 3
Reeza
Super User
If you want estimates for everything but the graph to be different then you'll likely have to do it externally using SGPLOT. You can capture the output and graph only elements you're interested in.
MFraga
Quartz | Level 8

Could you give an example of how I capture the output and graph only elements I am interested in for the "independent_v2", for example?

 

Thank you!

Reeza
Super User

Full code is here, except add a WHERE option on your data to filter out the categories you don't want to include.

 

https://blogs.sas.com/content/graphicallyspeaking/2014/02/09/survival-plot/

 

proc sgplot data=SurvivalPlotData (where = (group not in (list of types to exclude)));

At Risk table is optional obviously. 

 


@MFraga wrote:

Could you give an example of how I capture the output and graph only elements I am interested in for the "independent_v2", for example?

 

Thank you!


 

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1319 views
  • 1 like
  • 2 in conversation