Announcement

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

  • Calculating birth date based on age and date

    Hi all,

    I am trying to solve the following issue: I have a data set with a date, say date1, at which a certain procedure was done for each individual. I also have a variable for age of these individuals at date1. Is there a command which would allow me to create a birth date as a difference between date1 and age at date1? I'm only familiar with the opposite commands for calculating age from date durations etc.

    The dates are given in a Stata date "dmy" format, the age is calculated in years.

    Thank you!

  • #2
    That is not possible, but you can get a range within which the birth date must be. Lets say the date is today (19 sept 2024) and the person is 48 years old today, then that person could have been born 19 sept 1976, but he could also have been born 18 sept 1976 or the 17th sept 1976 ... all the way down to the 20th sept 1975.

    Code:
    . clear
    
    . input date age
    
              date        age
      1. 23638 48
      2. 22475 10
      3. end
    
    . format date %td
    
    .
    . gen month = month(date)
    
    . gen day = day(date)
    
    . gen year = year(date)
    
    . gen lb = mdy(month, day, year - age -1) +1
    
    . gen ub = mdy(month,day, year-age)
    
    . format lb ub %td
    
    . list
    
         +--------------------------------------------------------------+
         |      date   age   month   day   year          lb          ub |
         |--------------------------------------------------------------|
      1. | 19sep2024    48       9    19   2024   20sep1975   19sep1976 |
      2. | 14jul2021    10       7    14   2021   15jul2010   14jul2011 |
         +--------------------------------------------------------------+
    Last edited by Maarten Buis; 19 Sep 2024, 05:40.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment

    Working...
    X