Hi, everyone

The following claims data may include multiple stays for each person, but some stays are continuous. Specifically, it looks like a person was admitted to a hospital on 2012 May 17, and discharged on 2012 May 31 (row 312 in the below image). However, s/he actually stayed until 2012 December 31 (rows 313-319). So I'm wondering how to change the data in the way that continuous stays are treated as a single row. For example, I'd like to change the discharge date for the person to 2012 December 31, not 2012 May 31. However, the number of continuous stays differs by person.

It would be grateful if you could share some insights!

Thank you so much!!

Array