I have a variable BirthD (date of birth) (formatted as %td), and I have the variable Test_Date (date of when the diagnostic test was administered) (formatted as %td).
I am trying to create an age variable for the age at the time of the diagnostic test, where the age is expressed in months, and is rounded down to an integer value (e.g. if someone was 40 months and 5 days at the time), the age in months would be 40.
I have previously coded for a separate age variable in year (as opposed to months) but also rounded down using the following code:
gen TestDateYRS = floor((test_date - BirthD)/365.25)
Any suggestions for code to express this in months would be greatly appreciated.
I am trying to create an age variable for the age at the time of the diagnostic test, where the age is expressed in months, and is rounded down to an integer value (e.g. if someone was 40 months and 5 days at the time), the age in months would be 40.
I have previously coded for a separate age variable in year (as opposed to months) but also rounded down using the following code:
gen TestDateYRS = floor((test_date - BirthD)/365.25)
Any suggestions for code to express this in months would be greatly appreciated.

Comment