Hello,
I am finding challenging to get the below inrange() function to work with dates. I have a set of repeated measures over months for more than a thousand patients. Need to figure out whether or not the last time/date that a patient has visited a clinic is at or at about six months post the date of their respective initial visit (I am setting a range or buffer of 180 days plus/minus 12 days). The date variable is of the day/month/year (DMY) in Stata date format.
In some cases it is assigning a flag==1 when it clearly shouldn't. Thank you for any help.
I am finding challenging to get the below inrange() function to work with dates. I have a set of repeated measures over months for more than a thousand patients. Need to figure out whether or not the last time/date that a patient has visited a clinic is at or at about six months post the date of their respective initial visit (I am setting a range or buffer of 180 days plus/minus 12 days). The date variable is of the day/month/year (DMY) in Stata date format.
Code:
sort patientID visitdate by patientID (visitdate) : generate flag = 1 if inrange(`=visitdate[_N]',`=visitdate[1]+168',`=visitdate[1]+192') ta flag
Comment