Hi all, I will provide few more examples of my data, because it is more complex. The dot means missing data, it also means the treatment is "ongoing" If I have this : patientid name date_start date_end comment 1 drug A 23.06.2015 . here the dot disappear, regarding the following line 1 drug A 23.06.2015 25.09.2015 1 drug A 25.09.2015 . here the dot disappear, regarding the following line 1 drug A 25.09.2015 12.11.2015 1 drug A 13.11.2015 22.12.2015 2 drug B 12.11.2015 25.11.2015 2 drug B 26.11.2015 . here the dot disappear, regarding the following line 2 drug B 26.11.2015 22.06.2016 2 drug B 12.11.2016 25.11.2016 3 drug C 12.11.2015 25.11.2015 3 drug C 26.11.2015 . here we don't know what happened from 26.11.2015 to 12.11.2016, so we need to keep the dot. 3 drug C 12.11.2016 25.11.2016 4 drug D 12.11.2015 25.11.2015 4 drug D 26.11.2015 . here the dot disappear, regarding the following line 4 drug D 26.11.2015 22.06.2016 4 drug D 12.11.2016 25.11.2016 I would like in my final table to have this: patientid name date_start date_end 1 drug A 23.06.2015 22.12.2015 2 drug B 12.11.2015 22.06.2016 2 drug B 12.11.2016 25.11.2016 3 drug C 12.11.2015 . 3 drug C 12.11.2016 25.11.2016 4 drug D 12.11.2015 22.06.2016 4 drug D 12.11.2016 25.11.2016 Note: when we compare the previous end date with the following start date, we can say that drug intake is continuous if those two dates are same, or if the following start date is = previous end date+1. Also, note that I never have a dot in start date, its always in end date. It looks so complicated to me, I have a feeling this thing is impossible to resolve... Thank you very much +++ Kind regards.
... View more