Apologies because this question has likely been answered, I'm just struggling to search for it in the correct way. I have n = approx 3,000 subjects with around 40 clinic visit dates in wide format, and then two new disease diagnosis dates (two different diseases) from a newly merged dataset. ID date1 date2 date3 ... date40 diag_date1 diag_date2 1 2 . . What I need is to find a way to determine when diag_date1 and diag_date2 fit into the clinic visit date order, or to figure out between which two clinic visit dates the diagnosis dates occurred. Another problem is that date1 to date40 may not be chronological order. One idea I had is to transpose to long form and sort, but I don't know how to write code beyond that. Or is there a better way? I have SAS 9.4 Thank you so much in advance for your help!
... View more