I'm using longitudinal data, that includes up to four year-month (YEAR_MONTH) observations for each person (PERSON_ID). So each PERSON_ID has up to four records. Assuming the data are sorted by PERSON_ID and YEAR_MONTH, I want to generate a binary variable that flags with a "1" whenever PERSON_ID changes. The variable would take a value of "0" whenever current PERSON_ID and the prior record's PERSON_ID are the same. So I would like data that looks something like the following. Would appreciate any help with this. I'm sure it's more straightforward than I realize. Thank you very much.
| PERSON_ID | YEAR_MONTH | NEW_PERSON |
| 1 | 2020_1 | 1 |
| 1 | 2020_2 | 0 |
| 1 | 2020_3 | 0 |
| 1 | 2020_4 | 0 |
| 2 | 2020_1 | 1 |
| 2 | 2020_2 | 0 |
| 2 | 2020_3 | 0 |
| 2 | 2020_4 | 0 |
| 3 | 2020_1 | 1 |
| 3 | 2020_2 | 0 |
| 3 | 2020_3 | 0 |
| 3 | 2020_4 | 0 |
| 4 | 2020_1 | 1 |
| 5 | 2020_1 | 1 |
| 6 | 2020_1 | 1 |
| 7 | 2020_1 | 1 |
| 8 | 2020_1 | 1 |

Comment