I would like to keep one row of information for each ID which has the
preop_date or recpreop_date CLOSEST to the surgery date
Please note I've posted this as a continuation of another thread, but I thought as this is another question sepeate to the original post I thought I would post separately
Dataset:
preop_date or recpreop_date CLOSEST to the surgery date
Please note I've posted this as a continuation of another thread, but I thought as this is another question sepeate to the original post I thought I would post separately
Code:
//Select which is the correct pre_opdate (from the received vs preopdate) by finding the one closest to the operationdate //Generates the days from surgerydate gen preop_correct1 = abs(operationdate-preop_date) gen preop_correct2 = abs(operationdate-recpreop_date) //I then don;t know how to proceed from here
Dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float id str2 id2 float(pain scar surgdate oks gender preop_date recpreop_date postop_date recpostop_date operationdate) byte(_merge duplicatescores) 12 "1A" 1 1 22555 40 1 22533 22289 22770 22771 22555 3 0 13 "2B" 1 9 11962 1 2 11933 11933 11963 11782 11962 3 0 13 "2B" 1 9 11962 48 2 11932 11951 11963 11782 11962 3 1 13 "2B" 1 9 11962 48 2 11932 . . . . . 1 end format %td surgdate format %td preop_date format %td recpreop_date format %td postop_date format %td recpostop_date format %td operationdate label values _merge _merge label def _merge 3 "Matched (3)", modify
Comment