Announcement

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

  • Concatenate date of birth and calculate age

    Hi everyone,

    I have three variables, day, month and year. Day (1,2,3,etc.) and Year (1991,1992,1993, etc.) are numeric and month is string (Jan, Feb, Mar, etc.). I need these three to be one variable called 'dateofbirth'. How do I concatenate this?

    For the next step, I need to create a variable which gives us the age. So I need something like 'present date-dateofbirth'. How should I go about it?

    thanks!
    M

  • #2
    Stata's "date and time" variables are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

    All Stata manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

    To point you in the right direction, you will want something like
    Code:
    generate dateofbirth = mdy(month,day,year)
    format dateofbirth %td
    But please, before rushing to implement this, read the documentation. It's important.

    Comment


    • #3
      great, thanks william!

      Comment

      Working...
      X