Hello,
I would like to create start and end variables according to the data collection wave in which each participant's marital status changed.
I currently have ID, wave (1 to 5) and marstat (single, married, divorced) and I would like the data to look as follows:

ID Marstat Start End
1 Single 1 2
1 Married 2 4
1 Divorced 4 5
2 Married 1 5
3 Single 1 3
3 Married 3 5

I can't work out how to do this even though I am sure it is quite simple! Any advice would be most appreciated.
Many thanks,
Philippa