Announcement

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

  • Generating age variable in pannel dataset

    Hello Everyone!

    I was wondering if you could assist me in generating an age variable in a panel dataset I am working on.

    I have the date of the birth (date_birth) as well as the year variable (that indicates the year of the observation).

    I was trying to do (year - data_birth)/365.25

    However that is probably not working because while the year is yyyy, the date_birth is dd/mm/yyyy. How do I make the conversion?
    The specific date of the year we can use to calculate the age is not important for my analysis, as long as it is standard in the data.

    Also not sure if it is important, but I am using Stata 13

  • #2

    Think about the units of measurement. You can subtract daily dates from daily dates, or yearly dates from yearly dates, but you can't mix the two without a conversion factor

    In your case you can go

    (reference daily date (e.g. mdy(1, 1, year) MINUS date_birth ) / 365.25

    or

    year MINUS year(date_birth)

    See also this thread from yesterday: https://www.statalist.org/forums/for...-date-of-birth

    It's a good idea to search the forum before you post.

    Comment

    Working...
    X