Hi,

I know that many questions have been posted about working with dates in Stata. I have not been able to find an answer to my question, but apologies if this has already been covered. I would like to create a variable reflecting "age at death." I have four variables: birth month (float), birth year (float), death month (byte), death year (integer). Ideally, the "age at death" variable will be formatted as a fraction; 80.5 would be 80 years and 6 months old at death.

I don't know if I am on the right track. I converted the years and months to dates:

Code:
gen ymdobr=ym(bryear,brmonth)     // birth month/year
gen ymdodth=ym(dthyear,dthmonth)  // death month/year
I think I can then subtract:

Code:
gen agedth = ymdodth - ymdobr
If that's the correct step (don't know if it is), it is at this point that I am stuck. I probably need to format the agedth variable, since the variable's values currently range from 235 to 1173. As I mentioned, I am hoping that the agedth variable will have the age in years with one or two decimals for the months.

Thanks for your help,
Robbie