Hello,

I am working on a longitudinal dataset, with one or more observations/measures per patient. The first observation for each patient is their primary surgery (when they start being at risk); i.e, prim=1. Their subsequent observations are revisions of the primary surgery; i.e., revis==1. It is a multiple failure dataset, i.e. patients can fail repeatedly (i.e. have repeated revisions of the primary surgery). About 75% patients are censored.

I would like to calculate Kaplan Meier curves including risk tables for time to (first) revision, and cumulative revision rates, by type of catheters used in the primary surgery. Since sts graph and stptime excluded my censored patients, following Clyde Schechter advise, I added each participant an end-of-study observation at which they can be recognised as censored.

The numbers of catheter type at primary surgery are: 8113 ATB impregnated, 6005 Non-ATB impregnated and 6829 Unknown.

When I run the command sts graph with risktable option, the numbers at risk at time 0 are different: 8135 ATB impregnated, 5776 Non-ATB impregnated and 7036 Unknown. Can you advise about whether this is correct and, if not, about what might be happening?

I am copying below an example of my dataset (including only relevant variables) a description of the variables, and the commands I use.

Many thanks!

Rocio

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long id double opdati float(opss prim revis vantimiss forsu)
  102 1.5313008e+12 1 1 0 2 0
  102 1540566480000 2 0 1 2 0
  102 1560113820000 3 0 1 3 0
  102 1.5678213e+12 4 0 1 3 0
  102 1573131480000 5 0 1 2 0
  102 1.7041572e+12 6 0 0 2 1
  108 1.6597221e+12 1 1 0 1 0
  108 1689177120000 2 0 1 3 0
  108 1.7041572e+12 3 0 0 3 1
11023 1.4449005e+12 1 1 0 3 0
11023 1.7041572e+12 2 0 0 3 1
14034  1.508421e+12 1 1 0 1 0
14034 1.7041572e+12 2 0 0 1 1
14428 1.5173328e+12 1 1 0 2 0
14428 1.7041572e+12 2 0 0 2 1
15731 1.3938663e+12 1 1 0 2 0
15731 1.7041572e+12 2 0 0 2 1
15835 1.4331519e+12 1 1 0 3 0
15835 1.7041572e+12 2 0 0 3 1
16939 1.4118468e+12 1 1 0 2 0
16939 1.7041572e+12 2 0 0 2 1
16981 1.3920375e+12 1 1 0 2 0
16981 1.7041572e+12 2 0 0 2 1
17696 1.3921248e+12 1 1 0 2 0
17696 1.7041572e+12 2 0 0 2 1
18058  1.391967e+12 1 1 0 2 0
18058 1.7041572e+12 2 0 0 2 1
18225 1.6486323e+12 1 1 0 3 0
18225 1.7041572e+12 2 0 0 3 1
18803 1.4871666e+12 1 1 0 1 0
18803 1.7041572e+12 2 0 0 1 1
19011 1696419420000 1 1 0 2 0
19011 1.7041572e+12 2 0 0 2 1
19418  1.389261e+12 1 1 0 2 0
19418 1.5578331e+12 2 0 1 1 0
19418 1.7041572e+12 3 0 0 1 1
19419 1389796260000 1 1 0 1 0
19419 1477151940000 2 0 1 1 0
19419 1.4812161e+12 3 0 1 3 0
19419 1.5119676e+12 4 0 1 3 0
19419 1.7041572e+12 5 0 0 3 1
19420 1389534660000 1 1 0 2 0
19420 1.7041572e+12 2 0 0 2 1
19425  1.389021e+12 1 1 0 3 0
19425 1.4395554e+12 2 0 1 3 0
19425 1.7041572e+12 3 0 0 3 1
19426  1.389279e+12 1 1 0 2 0
19426 1.7041572e+12 2 0 0 2 1
19430 1389017820000 1 1 0 2 0
19430 1404141120000 2 0 1 2 0
19430 1.7041572e+12 3 0 0 2 1
19434 1389098460000 1 1 0 1 0
19434 1.7041572e+12 2 0 0 1 1
19495 1.3890225e+12 1 1 0 2 0
19495 1.7041572e+12 2 0 0 2 1
19601 1390408020000 1 1 0 2 0
19601 1.7041572e+12 2 0 0 2 1
19602 1.3906848e+12 1 1 0 2 0
19602 1.7041572e+12 2 0 0 2 1
19606 1.3891746e+12 1 1 0 2 0
19606 1.3915926e+12 2 0 1 2 0
19606 1.4018907e+12 3 0 1 2 0
19606 1443431460000 4 0 1 3 0
19606 1.7041572e+12 5 0 0 3 1
19607 1.3901418e+12 1 1 0 2 0
19607 1.3957356e+12 2 0 1 2 0
19607 1.3982433e+12 3 0 1 1 0
19607 1.7041572e+12 4 0 0 1 1
19609  1.389123e+12 1 1 0 3 0
19609 1.7041572e+12 2 0 0 3 1
19610 1389104220000 1 1 0 2 0
19610 1.7041572e+12 2 0 0 2 1
19611 1.3890189e+12 1 1 0 2 0
19611 1.4095053e+12 2 0 1 1 0
19611 1.7041572e+12 3 0 0 1 1
19623 1.3891404e+12 1 1 0 2 0
19623 1.3898844e+12 2 0 1 2 0
19623 1.3904907e+12 3 0 1 3 0
19623 1.3909299e+12 4 0 1 3 0
19623 1.3930086e+12 5 0 1 2 0
19623 1.3934097e+12 6 0 1 3 0
19623 1.7041572e+12 7 0 0 3 1
19626 1389108420000 1 1 0 2 0
19626 1.7041572e+12 2 0 0 2 1
19627 1.3891839e+12 1 1 0 2 0
19627 1.7041572e+12 2 0 0 2 1
19630 1.3959114e+12 1 1 0 2 0
19630 1.7041572e+12 2 0 0 2 1
19634 1.3898811e+12 1 1 0 2 0
19634 1.7041572e+12 2 0 0 2 1
19642 1.3909089e+12 1 1 0 1 0
19642 1.7041572e+12 2 0 0 1 1
19644 1391077020000 1 1 0 1 0
19644 1.3916874e+12 2 0 1 1 0
19644 1.7041572e+12 3 0 0 1 1
19645 1406194680000 1 1 0 3 0
19645 1.7041572e+12 2 0 0 3 1
19646 1.3895322e+12 1 1 0 2 0
19646 1.7041572e+12 2 0 0 2 1
19648 1.3909533e+12 1 1 0 3 0
end
format %tcDDmonCCYY_HH:MM opdati
label values prim yesnola
label values revis yesnola
label values forsu yesnola
label def yesnola 0 "No", modify
label def yesnola 1 "Yes", modify
label values vantimiss vantimissla
label def vantimissla 1 "ATB impregnated", modify
label def vantimissla 2 "Non-ATB impregnated", modify
label def vantimissla 3 "Unknown", modify
la var forsu "Observation added for survival analyses"
la var id "Patient id"
la var opdati "Date and time of surgery"
la var opss "Operation number"
la var prim "Operation is primary"
la var revis "Operation is revision"
la var vantimiss "Type of catheter"



Code:
* Declaring data to be survival-time data
stset opdati, id(id) en(opss==1) origin(prim==1) failure(revis==1)  scale(2635200000)

Code:
* Tabulating catheter type when prim==1 (i.e. time 0)
tab vantimiss if revis==0 & prim==1, m


Code:
* graph Kaplan-Meier survivor function
sts graph, failure by(vantimiss)  risktable legend(col(1)) xlabel(0(12)120)