I have a transaction log that consists of a customer ID, an activity date and a state entered. I am interested in reshaping to reflect the time spent in a given state. The challenge is that I can’t figure out how to access two rows at a time. I am also not 100% sure thats the best way to go.
Here is a simplified example of what the source data looks like
custID1, date1, state entered A, open
custID1, date2, state entered B, action
custID1, date3, state entered C, action
custID1, date4, state entered C, update (updated without state change)
custID1, date5, state entered D, close
here is what I am looking to build
custID1, date1, state entered A, date2, state entered B
custID1, date2, state entered B, date3, state entered C
custID1, date3, state entered C, date4, state entered C
custID1, date4, state entered C, date5, state entered D