BookmarkSubscribeRSS Feed
Ata62439
Calcite | Level 5
Hi All,
Need your expertise to solve below data.
Apps Code Date
590345 R33 31-Oct-23
590345 R34 31-Oct-23
590345 R33 30-Oct-23
590346 R21 28-Oct-23
590346 R19 20-Oct-23

And my expected result will be
Apps Code Date
590345 R33 31-Oct-23
590345 R34 31-Oct-23
590346 R21 28-Oct-23

So as you can see I'm only want data with maximum date on each Apps variable.
Appreciate if you can help me to solve this

Thank you folks!
3 REPLIES 3
sbxkoenk
SAS Super FREQ

Not sure what it has to do with data mining, but here you go:

data have;
format Date date9.;
input Apps Code $ Date : date9.;
datalines;
590345 R33 31-Oct-23
590345 R34 31-Oct-23
590345 R33 30-Oct-23
590346 R21 28-Oct-23
590346 R19 20-Oct-23
;
run;

PROC MEANS data=have MAX noprint;
 CLASS Apps Code;
 var Date;
 types Apps;
 output out=statmax max= / autoname;
run;

PROC SQL noprint;
 create table want as 
 select *
 from have
 where strip(put(Apps,6.))!!strip(put(Date,date9.)) 
       IN (select strip(put(Apps,6.))!!strip(put(Date_Max,date9.))
	       from statmax);
QUIT;
/* end of program */

Koen

Reeza
Super User
proc sql;
create table want as
select * 
from have
group by apps
having date=max(date);
quit;

This will work in SAS.

 


@Ata62439 wrote:
Hi All,
Need your expertise to solve below data.
Apps Code Date
590345 R33 31-Oct-23
590345 R34 31-Oct-23
590345 R33 30-Oct-23
590346 R21 28-Oct-23
590346 R19 20-Oct-23

And my expected result will be
Apps Code Date
590345 R33 31-Oct-23
590345 R34 31-Oct-23
590346 R21 28-Oct-23

So as you can see I'm only want data with maximum date on each Apps variable.
Appreciate if you can help me to solve this

Thank you folks!

 

 

sbxkoenk
SAS Super FREQ

Oeps 🙁.
A bit more straightforward than my code (and less lengthy = more concise).

Koen

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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