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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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