Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Survival Analysis - Checking Median survival at Different Year

    Hello. I am working on Stata 17 on windows. Trying to find the median survival improvements on a yearly basis (e.g. how does median survival in 2021 compare to median survival in 2020 vs 2019 vs 2018, etc.) for two groups. I am looking at a 33 year period (and have correctly generated year function for time purposes), so I was trying to look at median survival time at different years by manipulating the exit date.

    Code:
     stset year, failure(fail==1)id(pt_code)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 33)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 32)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 31)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 30)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 29)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 28)
    by group, sort:stsum
     
    stset year, failure(fail==1)id(pt_code) exit(time 27)
    by group, sort:stsum
    However, when I run this code, I am getting the same results for the sort:stsum outputs.


    Click image for larger version

Name:	Screenshot_14.png
Views:	1
Size:	16.7 KB
ID:	1647637
    Click image for larger version

Name:	Screenshot_1.png
Views:	1
Size:	14.9 KB
ID:	1647638

    Click image for larger version

Name:	Screenshot_3.png
Views:	1
Size:	14.8 KB
ID:	1647640
    Click image for larger version

Name:	Screenshot_2.png
Views:	1
Size:	16.6 KB
ID:	1647639

  • #2
    It's not 100% clear to me how you have set up your analysis and what you're trying to do, but these results don't surprise me.

    Consider the analysis where you've used exit(time 22). You're telling Stata that the survival times of anyone still alive at 22 years should be censored at 22 years. You then see that the median survival for group 0 is 2.186 years. That is, the survival curve drops below 50% for the first time at 2.186 years.

    Now consider what happens if, instead, you force everyone to be censored at 21 years. The survival curve up to 20 years will not change and the estimated medians for groups 0 and 1 will not be affected.

    You write that you "correctly generated year function for time purposes". I would like to see more details of how you did that.

    In addition, "median survival time at different years" can mean different things. Do you mean for year of entry (standard) or year of follow-up? The fact that you are manipulating the exit date suggests you may be attempting to do something non-standard (and that I don't fully understand). My apologies if I have misunderstood.

    Comment


    • #3
      Thank you for the pointers.

      1).
      Code:
      generate atime = ptime if tx_date~=.
       
      generate btime = dayswait_chron if tx_date == . & ssdmf_death_date==. & death_date == .
       
      generate ctime = ssdmf_death_date - init_date if tx_date == . & ssdmf_death_date~=.
       
      generate dtime = death_date - init_date if tx_date==. & ssdmf_death_date==. & death_date ~=.
       
      generate etime = chg_date - init_date if chg_date ~= . & inact_reason==7 & death_date == . & ssdmf_death_date==.
       
      recode atime btime ctime dtime etime(.=0)
       
      generate time = atime + btime +ctime + dtime + etime
       
      generate year = time /365
      2). I am tracking the survival of participants from 1987 to 2020 by looking at the year of entry. Year 33 should correlate to 2020 (time 33). I want to see how median survival time improved in recent years. For example, what was the median survival time recorded in 2018, and how does that compare to 2019, etc. But I guess that my time variable (year) is looking at years of survival time and not calendar year. I need a calendar year for exit time in this case. However, I don't think my database has a time value that is independent of participant survival time. Is there any way that Stata can calculate incremental yearly improvements?

      Comment


      • #4
        Is there any way that Stata can calculate incremental yearly improvements?
        Yes, but first you need to get your data set up correctly. I think you need to separate the variables related to survival time from the variables on patient characteristics. I view year of diagnosis as a patient characteristic.

        For the survival part you need the following variables (with names suggested by me):
        1. date of entry (entry_date)
        2. date of exit (exit_date)
        3. event indicator (dead)

        You then use:

        Code:
        stset exit_date, failure(dead) enter(time entry_date) scale(365.24)
        This tells Stata that the survival time for each patient is from entry_date until exit_date. We optionally divide by 365.24 to rescale from days to years.

        It looks like entry_date will be equal to init_date, but I don't fully understand your data (I see you have treatment date and various other dates).

        exit_date will probably be death_date for those who die but you need to add date of last follow-up for those who didn't die.

        You can then potentially do something like:

        Code:
        by year group, sort:stsum
        If you wanted to make inference about changes in the median with year then you could use quantile regression.

        Comment

        Working...
        X