BookmarkSubscribeRSS Feed
shivagujjaru
Calcite | Level 5
Id. Dateofjoining
101 21Aug2018
102 22Aug2018
103 17Aug2018
104 25Aug2018

As per series 103 should be 23 or 24 Aug . How to pick the odd one out or remove 103 row.
4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

please try

 

data have;
input Id Dateofjoining :date9.;
diff=coalesce(dif(Dateofjoining),0);
if not (diff<0);
cards;
101 21Aug2018
102 22Aug2018
103 17Aug2018
104 25Aug2018
105 27Aug2018
106 18Aug2018
107 30Aug2018
;
Thanks,
Jag
Ksharp
Super User
data have;
input Id Date : date9.;
format date date9.;
cards;
101 21Aug2018
102 22Aug2018
103 17Aug2018
104 25Aug2018
;

data want;
 set have;
 retain temp;
 if temp<date then temp=date;
  else flag=1;
  drop temp;
run;
shivagujjaru
Calcite | Level 5
What value does temp represent here
Ksharp
Super User

temp hold the max date when go through the table.

 

101 21Aug2018
102 22Aug2018
103 17Aug2018
100 18Aug2018 104 25Aug2018
;

103 and 100 is you want removed ? 

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
  • 4 replies
  • 1398 views
  • 0 likes
  • 3 in conversation