I've got some historical policy data, and I need to fix a couple of errors in it.
The part I'm struggling with is what to do with records 39 and 40. We're going to treat the date the change from coverage_status 1 to coverage_status 4 happened as 6/29/2009, which can be found in row 41 in the transaction_date column. I want to have have a period_start and period_end column for the records in rows 39 and 40. For record 39, I want the period_start to be 4/1/2009, and the period end to be 6/28/2009, and for record 40, I want the period_start to be 6/29/2009, and the period_end to be 6/30/2009.
Since these dates are in different rows, I'm having a hard time getting this to work systematically for different scenarios.
I've attached my starting point, and my desired output is included as well.
Any ideas how this can be done?