Announcement

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

  • Death Dates-Converting MONTH and YEAR

    Hi, Im doing survival analysis with secondary data. I have two variables [MONTH] and [YEAR] I also have Birth data. I can sort respondents by person number, Household ID


    1) How do I transform these into a DEATHDATE

  • #2
    Hard to say. Do you have information on deaths?

    Comment


    • #3
      Perhaps your MONTH and YEAR are meant to be the month and year of death. In that case, the answer depends very much on what your birth data are like.

      In order to get a helpful response, you need to show some example data.

      Be sure to use the dataex command to do this. If you are running version 15.1 or later, or a fully updated version 14.2, dataex is already part of your official Stata installation. If not, run ssc install dataex to get it. Either way, run help dataex and read the simple instructions for using it. dataex will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

      When asking for help with code, always show example data. When showing example data, always use dataex.

      Comment


      • #4
        Assuming your month and year variables are month and year of death you don't need birth date to calculate date of death. You can create a monthly date as
        Code:
        gen deathdate=ym(year,month)
        format deathdate %tm
        If your goal is age at death then the birth date would matter.

        Regardless of your goal I would highly recommend reviewing the FAQ for this forum. There is a lot of good information there on how to structure your question so that we can most easily help you, including information on showing sample data.

        Comment


        • #5
          Sorry, I'm a new postdoc. I have never done survival models before. I am merging death data into a master data set that is long format. My time variable will be wavey (number of years in observation since wave 3 or baseline).

          I have month and year of both birth and death. I also have date of initial interview so i know when they entered the study also. I am interested in knowing how long people survive following a probable stroke and probable Alzheimer's, in months. I have 12 waves of data from a large US dataset.

          Things that are unique to this dataset -

          STRL (probable time in years (linked to wavey) at which where stroke occurs)

          FIT (model fit or stroke when stroke fits better it’s deviation from line)

          WISTR (has a stroke-like decline observed in episodic memory data)

          FITLIN (linear fit on aging pattern for that person)

          wavey (number of years in observation since wave 3 or baseline)

          ADRL (probable time in years (linked to wavey) at which where AD starts)

          FITA (model fit or ADRD when ADRD fits better it’s deviation from linear)

          IADR1 (unnecessary)

          WIADR (don’t need this)

          ADRD (has an AD-like decline observed in episodic memory data)

          Comment


          • #6
            generate born= 12*BIRTHYR+BIRTHMO
            generate ddied=12*KNOWNDECEASEDYR+KNOWNDECEASEDSOURCE
            generate ALIVE1= ddied-born

            Comment


            • #7
              dataex 1/5

              1 invalid name

              Comment


              • #8
                try
                Code:
                dataex in 1/5

                Comment


                • #9

                  . dataex born ddied ALIVE1 in 1/5

                  ----------------------- copy starting from the next line -----------------------
                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input float(born ddied ALIVE1)
                  23258 23941 683
                  23218 24013 795
                  23233 24157 924
                  23265 24181 916
                  23274     .   .
                  end
                  ------------------ copy up to and including the previous line ------------------

                  Listed 5 out of 43216 observations

                  Comment


                  • #10
                    I would probably recommend using Stata data variables to do the calculations but what you've done will work. You could do it this way with monthly dates.

                    Code:
                    gen born=ym(BIRTHYR,BIRTHMO)
                    gen ddied=ym(KNOWNDECEASEDYR,KNOWNDECEASEDSOURCE)
                    gen ALIVE1=ddied-born
                    Either way ALIVE1 is the number of months alive (or age at death in months).

                    As an aside, have you specified the variable for month of death correctly? I would expect the variable KNOWNDECEASEDSOURCE to be a variable telling you where the death information came from.

                    Comment

                    Working...
                    X