BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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;
1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1
yabwon
Onyx | Level 15
last.ID ...

Use Maxim 1 and read here: https://documentation.sas.com/doc/en/lrcon/9.4/p05cyvj8ur5f02n1uq3thhxd3pat.htm

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1 reply
  • 509 views
  • 3 likes
  • 2 in conversation