I want to say first how great a resource this forum has been for me while dealing with some very (extremely!) messy data. Thank you for your help and I have one more issue I would like to see if I can find an answer to. I have records containing IDs, type, begin date, and various other indicators. They are sorted by id and begin date. For each ID, I would like to collapse the rows that are consecutive days in type ‘a’ into one row, while keeping the most common value of the other indicators (dx1 dx2), moving the last ‘begin date’ of the range to an ‘end date’ column, and keeping other type ‘b’ rows intact. See below: data have; input id type begin_date end_date dx1 dx2 datalines; 1 A 28JAN2019 . a b 1 A 29JAN2019 . a b 1 A 30JAN2019 . a a 1 A 31JAN2019 . b b 1 B 2FEB2019 . a b 2 B 29JAN2019 . b c 2 A 1FEB2019 . b d 2 A 2FEB2019 . b d 2 A 3FEB2019 . a b 2 A 4FEB2019 . a d 2 A 5FEB2019 . b b ; run; data want; input source id begin_date end_date dx1 dx2 datalines; 1 A 28JAN2019 31JAN2019 a b 1 B 2FEB2019 . a b 2 B 29JAN2019 . b c 2 A 1FEB2019 5FEB2019 b d ; run; I’m not sure where even to begin with this one, so any help that can be provided will be much appreciated!
... View more