Hi everyone,
I'm looking to find the exact age of survey participants in months. Right now I'm subtracting the date the participant was born from the date the survey took place with the code
both CB_DOIW and participant_DOB are in %td format.
This gives the wrong results. Participants who did the survey on their birthday, ie:
CB_DOIW = 19/3/2021
participant_DOB = 19/3/2013
should have their ageinmonths be equal to 96, instead the above code gives .6668489 as an answer. I'm unsure of what I'm doing wrong here.
To be clear, I need the ageinmonths to be exact, ie,
if CB_DOIW = 19/3/2021 and participant_DOB = 18/3/2013, I should get a value of 96.032, or if the month was April
CB_DOIW = 19/4/2021
participant_DOB = 18/4/2013
ageinmonths should be 96.033
I'm looking to find the exact age of survey participants in months. Right now I'm subtracting the date the participant was born from the date the survey took place with the code
Code:
gen ageinmonths= (CB_DOIW - participant_DOB)/(365.25/12)
This gives the wrong results. Participants who did the survey on their birthday, ie:
CB_DOIW = 19/3/2021
participant_DOB = 19/3/2013
should have their ageinmonths be equal to 96, instead the above code gives .6668489 as an answer. I'm unsure of what I'm doing wrong here.
To be clear, I need the ageinmonths to be exact, ie,
if CB_DOIW = 19/3/2021 and participant_DOB = 18/3/2013, I should get a value of 96.032, or if the month was April
CB_DOIW = 19/4/2021
participant_DOB = 18/4/2013
ageinmonths should be 96.033
Comment