Hello,
I have a dataset like this :
| ID | date | days |
| ID1 | 02/03/2017 | 28 |
| ID1 | 30/03/2017 | 30 |
| ID1 | 01/05/2017 | 7 |
| ID1 | 10/05/2017 | 90 |
| ID2 | 24/12/2018 | 14 |
| ID2 | 09/01/2019 | 56 |
| ID2 | 06/03/2019 | 20 |
I want to add a flag which will take 1 if there is 3 consecutive months (90 days) by ID -a gap of 1 or 2 days is allowed- otherwise will take 0 :
| ID | date | days | end_date | flag |
| ID1 | 02/03/2017 | 28 | 30/03/2017 | 0 |
| ID1 | 30/03/2017 | 30 | 29/04/2017 | 0 |
| ID1 | 01/05/2017 | 7 | 08/05/2017 | 0 |
| ID1 | 10/05/2017 | 90 | 08/08/2017 | 1 |
| ID2 | 24/12/2018 | 14 | 07/01/2019 | 1 |
| ID2 | 09/01/2019 | 56 | 06/03/2019 | 1 |
| ID2 | 06/03/2019 | 20 | 26/03/2019 | 1 |
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.