Some patient received an treatment as treated group and some did not as control group. In order to consider "immortal time bias", I coded the treatment as a time-dependent covariate. Could you let me know it is right or not? Thanks. For example, there are two patients: P1 received the treatment 30 days after the start of this study and died 30 days after receiving the treatment. P2 did not received the treatment and survived at the end of this study (80 days). Here I code the data as follow:
ID Treatment Time Death
P1 0 30 0
P1 1 30 1
P2 0 80 0
Then I just used SAS code to create KM curves
/*Survival curve*/
proc lifetest data=treatment;
time Time*Dearg(0);
strata Treatment;
run;