Hi my fellow stata users. I have multiple diagnosis dates for different conditions per individual patient. I am trying to keep the earliest diagnosis date per condition per patient. I have tried the following command -bysort ID ( CCI_date) : keep if _n == 1-
but I incorrectly keep the earliest diagnosis date overall and not by each condition. I want to end up with several diagnosis dates per patient, but each diagnosis date will correspond to a different condition. I hope that's not too confusing!
Thanks you in advance. Below is sample data:
but I incorrectly keep the earliest diagnosis date overall and not by each condition. I want to end up with several diagnosis dates per patient, but each diagnosis date will correspond to a different condition. I hope that's not too confusing!
Thanks you in advance. Below is sample data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str1 ID byte charlson_category float CCI_date "1" 1 14976 "1" 3 15721 "1" 3 15734 "1" 6 21375 "2" 6 21375 "2" 4 11688 "2" 6 20977 "2" 6 20576 "2" 6 20233 "2" 6 20233 "2" 4 20030 "3" 4 19710 "3" 6 20627 "3" 6 20258 "4" 6 20258 "4" 4 21339 "4" 6 21025 "4" 4 11688 "5" 4 19682 "5" 1 19780 end format %td CCI_date label values charlson_category charlson_category label def charlson_category 1 "Any malignancy", modify label def charlson_category 3 "Chronic pulmonary disease", modify label def charlson_category 4 "Congestive heart failure", modify label def charlson_category 6 "Diabetes", modify
Comment