Hi everyone, I have an input data that looks like this. The data has two subjects with ID1 and ID2 ID Start_date End_date 1 1/1/2010 4/1/2010 1 4/24/2010 6/1/2010 1 9/1/2010 10/15/2010 2 3/1/2010 5/1/2010 2 6/1/2010 10/1/2010 Basically, I want to collapse the multiple start and end dates for each subject into one contiguous start and end date per each subject. However, there is a twist. If the gap between the end date and next start date for the subject is greater than 45 days, then the dates are not collapsed for that row of observation. I have highlighted the desired start and end dates for each subject. The output dataset should look like ID Start_date End_date 1 1/1/2010 6/1/2010 1 9/1/2010 10/15/2010 2 3/1/2010 10/1/2010 Note that subject 1 has a gap greater than 45 days (from 6/1/2010 to 9/1/2010), so the row from 9/1/2010 to 10/15/2010 is not collapsed with the first two rows for subject 1. Subject 2 has no gap greater than 45 days, so his two rows of start and end dates are collapsed. Thank you so much for your help. gary
... View more