Announcement

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

  • Changing Age to Months for Children under the Age of 5

    Hi all,

    I'm trying to calculate the HAZ, WAZ, WHZ and BMIZ for 3 different age categories, 0-60months, 5-9 years and 10-19 years. However I have read that zanthro is more sensitive as the age becomes smaller, so I require months instead of years.

    I have checked a few threads but none I've found go far enough, I have different variables for the month the child was born, the year they were born, the month the survey was conducted, the year the survey is conducted and a dummy variable for whether the child is under 5 years old (as I only want to convert to months for below 5).

    Thanks in advanced, if I haven't provided enough information let me know.
    Alex

  • #2
    Hi Alex, welcome to the Statalist. The description of your dataset would be better with a minimal data example (using -dataex-) as explained in the FAQ. It doesn't need to be real data, it can be fake, so long as it reproduces the characteristics in your real dataset and problem. To that end, I am going to guess at what your dataset looks like, and give you a starting point for how to approach your situation.

    The trick is to first create a date variable (in Stata's internal format) for both the birth month and year, and the survey month and year. Then it's simple algebra to find the elapsed number of months. If you are given month or year in strings, then the obvious first step will be to convert those to integers.

    Code:
    clear
    input byte month_born int year_born byte month_survey int year_survey
    3 2003  4 2003
    1 2002  5 2005
    2 2006  8 2010
    3 2003  9 2005
    4 2001 12 2002
    end
    
    gen int born_date = mofd(mdy(month_born, 1, year_born))
    gen int survey_date = mofd(mdy(month_survey, 1, year_survey))
    format %tm born_date
    format %tm survey_date
    
    gen age_months = survey_date - born_date + 1
    list, abbrev(20)
    result

    Code:
    . list, abbrev(20)
    
         +--------------------------------------------------------------------------------------------+
         | month_born   year_born   month_survey   year_survey   born_date   survey_date   age_months |
         |--------------------------------------------------------------------------------------------|
      1. |          3        2003              4          2003      2003m3        2003m4            2 |
      2. |          1        2002              5          2005      2002m1        2005m5           41 |
      3. |          2        2006              8          2010      2006m2        2010m8           55 |
      4. |          3        2003              9          2005      2003m3        2005m9           31 |
      5. |          4        2001             12          2002      2001m4       2002m12           21 |
         +--------------------------------------------------------------------------------------------+

    Comment


    • #3
      Thank you so much this was exactly what I was looking for, next time I'll make sure to include a minimal data example.

      Comment

      Working...
      X