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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 1297 views
  • 0 likes
  • 3 in conversation