Hi!
I have a large dataset with follow-up observations for patients following a surgical event. The patients are followed up annually, however, in reality this means annually ish. Therefore, we have decided that patients who was seen between the days 548 and 914 are counted as annual followup year two (counted as 365,25x2=730,5), by using this code:
All great in theory - however, in practice, there are patients who have had two followups within this time period. We would like to keep the one closest to the true annual number of days, meaning that if a patient had two followups during the time period for year 1, eg day 320 and day 547, we keep the one on day 320.
Is there any way you could write a script that does this? I'm unfortunately not skilled enough but I have realized that it's not manageable to do manually for 200,000 observations...
Eternally grateful!
I have a large dataset with follow-up observations for patients following a surgical event. The patients are followed up annually, however, in reality this means annually ish. Therefore, we have decided that patients who was seen between the days 548 and 914 are counted as annual followup year two (counted as 365,25x2=730,5), by using this code:
Code:
. generate daysfromintervention= datediff(INTERVENTION_DATE, FOLLOWUP_DATE, "day"> ) . generate followuptime =. . replace followuptime=1 if (daysfromintervention>=274 & daysfromintervention<548) . replace followuptime=2 if (daysfromintervention>=548 & daysfromintervention<914) . replace followuptime=3 if (daysfromintervention>=914 & daysfromintervention<1279) *and then individually, creating different datasets for each yearly followup . keep if followuptime==1 . duplicates tag TRR_ID_CODE, generate(tags) . save as xxxx
Is there any way you could write a script that does this? I'm unfortunately not skilled enough but I have realized that it's not manageable to do manually for 200,000 observations...
Eternally grateful!
Comment