Dear Stata Forum,

My research question: Among people who have had a kidney transplant, what are survival probabilities for death (question A), and graft failure (question B) by diabetes status (type 1 vs. type 2)?

For Question A
, i have done a simple kaplan meier curve and a log-rank test to assess survival curves between type 1 and type 2 diabetes. Code below
(using stata version 16.0):

stset dox, fail(fail==1) origin(time tx1date) entry(tx1date) scale(365.25) id(id),
where fail = death, dox = date of exit, and tx1date is date of transplant.
sts graph, by(diab_type) ci
sts list, at(1 5 10 15) by(
diab_type
)


My research paper includes a nice Kaplan Meier figure depicting the survival probabilities over time, for those with type 1 vs type 2 diabetes, and a table below citing the survival probabilities at years 1, 5, 10 and 15.


For Question B
, death is a competing risk for graft failure and thus I cannot use the Kaplan Meier as it will overestimate survival probabilities. Thus, I have been doing some research on the
stcompet function, but cannot seem to get a handle
on how to use it appropriately.

the code I have to date:
gen fail3 = 0
replace fail3 = 2 if fail==1
replace fail3 = 1 if fail2==1
(where fail = death, and fail2 = graft failure)

stcompet CI=ci UL=hi LL=lo, compet1(2) by(diab_type)

This seems to run ok.

My question: from here - how do i:
(i) get a graph similar to the kaplan meier
(ii) get estimates of graft failure survival probabilities at years 1, 5, 10 and 15?
(iii) compare survival curves (similar to the log-rank that i used for kaplan meier)?

Any help is most welcome.

Jess