Hello friends,
I want to select last row by group .
This code below create a data set with one row only and not one row by group.
Why did it happen and what is the way to solve it?
data have;
input ID $ date : date9. var;
format date date9.;
cards;
A 01JAN2023 10
B 05JAN2023 5
B 06JAN2023 6
C 15JAN2023 7
C 16JAN2023 8
C 19JAN2023 9
C 20JAN2023 10
D 24JAN2023 2
;
Run;
proc sort data=have;
by ID date;
Run;
Data Way2;
set have end=last;
by ID;
if last then output;
run;
last.ID ...
Use Maxim 1 and read here: https://documentation.sas.com/doc/en/lrcon/9.4/p05cyvj8ur5f02n1uq3thhxd3pat.htm
last.ID ...
Use Maxim 1 and read here: https://documentation.sas.com/doc/en/lrcon/9.4/p05cyvj8ur5f02n1uq3thhxd3pat.htm
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 16. Read more here about why you should contribute and what is in it for you!
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.