How can i deduplicate a dataset by ID1 and ID2, if I have the next structure:
ID1 ID2 DATE VALUE
1000 10 31JAN2016 5
1000 10 26FEB2016 6
1000 10 31MAR2016 7
The result that I expectedis:
ID1 ID2 DATE VALUE
1000 10 31MAR2016 7
(Which is the most current date according to the date)
Use proc sort.
proc sort data=have;
by id id2 date; run;
data want;
set have;
by id id2;
if last.id2;
run;
Use proc sort.
proc sort data=have;
by id id2 date; run;
data want;
set have;
by id id2;
if last.id2;
run;
No, it has to be a variable listed in the BY statement.
And it picks the last of that group, based on your specifications, this is what was required, but you can modify it to fit your needs, if you have more variables or something.
You can review the documentation on how BY groups are processed and the FIRST/LAST variables and how they're calculated.
I find the examples and illustrations here helpful:
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.