Hi stata list,
I’m using STATA 12.1 and would like to calculate a person’s age. I’m
generating ‘synthetic’ dates drawing from the uniform distribution as
below:
gen month_dob=int(1+(13-1)*runiform())
gen day_dob=int(1+(32-1)*runiform())
gen year_dob=int(1964+(1999-1964)*runiform())
gen date_of_birth=mdy(month_dob, day_dob, year_dob)
format date_of_birth %d
di date_of_birth
I’m able to obtain the current system/stata date by:
gen today_date=c(current_date)
di today_date
Theoretically subtracting the today_date from date_of_birth should
give the age, I’m encountering some problems subtracting these two
dates. Could this be due to date formats i.e. month day year (MDY)
versus day month year (DMY). Or it could be due to one date being an
integer and the other a string? Or it's something else?
Please assist.
Kind regards
G
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/