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;