Announcement

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

  • Calculating birthdate from age and age at test date

    How do I calculate birthdate from the age at test date (ageIGA) and the test date (tvdIGA)?

    Variables are below

    dataex tvdIGA ageIGA

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int tvdIGA double ageIGA
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    19588 10.4
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21135 14.1
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    21268 12.3
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    19678  4.7
    end
    format %tddd-Mon-YY tvdIGA

  • #2
    If you need an exact birthdate, that isn't possible because your ages are rounded to tenths of a year, hence they represent an interval of approximately 36-37 days, not an exact age in days. But you can get a reasonable approximation as follows:

    Code:
    gen approx_birth_date = tvdIGA - round(365.25*ageIGA)
    format approx_birth_date %td

    Comment


    • #3
      Great. The code works wonderfully.

      Thank you Clyde!

      Cheers,
      Aaron

      Comment


      • #4
        By the way I would look very carefully at your age data. I have seen data with decimal parts .1 .11 .12 .2 .3 .4 .5 .6 .7 .8 .9. What happened should be clear enough! Even then it might to hard to check whether .1 means 1 or 10.

        Conversely, if ages were in years and months I would expect decimals like 0.08, 0.17, 0.25 (to 2 d.p.).

        Perhaps your data really are years and tenths, but do check.
        Last edited by Nick Cox; 03 Oct 2019, 01:43.

        Comment

        Working...
        X