Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Calculate Age in years and months between 2 dates


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Calculate Age in years and months between 2 dates
Date   Thu, 5 Jan 2012 18:04:54 +0000

Yes, but I wouldn't do that. 

Consider someone born 21 April 1926 whom we interview today:  

. di mofd(mdy(1,5,2012)) - mofd(mdy(4, 21, 1926))
1029

Her age is 85 completed years and 9 months. 

. di floor(1029/12)
85

. di mod(1029,12)
9

So, get the month from -mofd()- and proceed from that. Some rounding, but you seem to want that. 

Nick 
[email protected] 

Kanter, Rebecca

I am trying to calculate age in years and months betweeen an interview date (date1) and a birthdate (date2).

For example, if the interview date was 13 Sept 2011 and a birthdate is 06 Jan 2000 such that

and Age = (date1 - date2) / 365.25 = 11.68515

then this person is 11 years and 8 months (12*.68515 = 8.22)

or another example interview date was  18 Oct 2011 and birthdate is 06 Nov 2001 (Age = 9.946612)

so this person is 10 years and 11 months (12*.946612 = 11.36)

So I need to create a new month variable ...is there a way at least to truncate Age at the decimal point and multiply it by 12 ... ?


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index