BookmarkSubscribeRSS Feed
SAS03
Calcite | Level 5

Hello,

I have a dataset like this :

IDdatedays
ID102/03/201728
ID130/03/201730
ID101/05/20177
ID110/05/201790
ID224/12/201814
ID209/01/201956
ID206/03/201920

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 :

 

IDdatedaysend_dateflag
ID102/03/20172830/03/20170
ID130/03/20173029/04/20170
ID101/05/2017708/05/20170
ID110/05/20179008/08/20171
ID224/12/20181407/01/20191
ID209/01/20195606/03/20191
ID206/03/20192026/03/20191

 

3 REPLIES 3
Ksharp
Super User
Why not the third obs take flag=1 ? since the gap is only two days .
SAS03
Calcite | Level 5
The sum days of the 3 first rows is 65days < 90 days, that's why the third row will have 0 and not 1
Ksharp
Super User
Then the second obs ? since the gap is only two days . 29/04/2017 --> 01/05/2017

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1014 views
  • 0 likes
  • 2 in conversation