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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 736 views
  • 4 likes
  • 3 in conversation