Announcement

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

  • Converting Date or birth to Age

    Hello,
    It's first time I am using this forum. I have previously converted successfully date of birth (dob) to age; most of the time the dob was string. I have now a dob variable which is of the type "numeric daily date (int)", and the format is as follows 5/15/2009 (for May 15, 2009), 6/8/82 (for June 8, 1982), etc. I have tried to convert this dob to stata date (in string format) before converting to age, but am stuck. Grateful for your help. Thanks. Daya

  • #2
    Stata dates are not strings; it sounds like you already have what you probably want; please read
    Code:
    help datetime
    I also suggest you read the forum FAQ which has good advice on how to ask questions and how to show example data

    Comment


    • #3
      Suppose you want age at 31 December 2019. Then in many fields this approximation is deemed good enough.


      Code:
      gen age = (mdy(12, 31, 2019) - dob) / 365.25
      For daily date variables, the display format is immaterial to this problem. It is the use of a numeric storage type holding daily dates relative to 1 January 1960 (which isn't best called a format).

      Comment


      • #4
        Thank you Rich and Nick. The command from Nick worked very well!
        Thanks again.

        Comment

        Working...
        X