Hi Freelance Reinhard! Your code worked beautifully. Thank you for putting it together. However, when I went to apply it to my actual dataset, it wasn't working. It was here that I realized the set-up I had in my sample 'have' dataset is different than my actual one. Apologies for wasting your time. My actual dataset has continuous days starting from the beginning of the entire dataset vs starting from the enrollees start date. (i.e. day1 always equals 01/01/2015, regardless of the enrollee's start date) So using my same sample dataset, here's a revised sample dataset. I've revised some of the dates, but rules still apply. data have; input ID $ Start_Date $ Day1 Day2 Day3 Day4 Day5 Event_date; datalines; AA 01/01/2015 1 1 1 1 1 01/04/2015 BB 01/03/2015 . . 1 1 1 . CC 01/04/2015 . . . 1 . . DD 01/01/2015 1 1 1 . 1 02/15/2015 EE 01/01/2015 1 1 1 1 1 . FF 01/02/2015 . 1 1 1 1 01/03/2015 ;; run; AA start_date=01/01/2015 and end_date=01/04/2015 *date of event BB start_date=01/03/2015 and end_date=01/05/2015 *date of last enrollment; CC start_date=01/04/2015 and end_date=01/04/2015 *date of last enrollment; DD start_date=01/01/2015 and end_date=01/03/2015 *date of last enrollment EE start_date=01/01/2015 and end_date=01/01/2015 *date of last enrollment FF start_date=01/02/2015 and end_date=01/02/2015 *date of event;
... View more