BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BETO
Fluorite | Level 6

hi I haveatablewhere I want to get max date  for example

have

id. Date            type.  comp

a. 07/15/15       A1.      Yes

b 07/16/15.        A2.       No

a 07/18/15.         A2.      Yes

c 07/15/15.          A3.       No

what I want is to pull the max date which is he last time it was service

out put

a.07/18/15   A2.   yes

b 07/16/15.  A2    No

c 07/15/15.  A3.    No

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Also try the sql method

proc sql;

create table want as select a.* from have as a, (select max(date) as date, id from have group by id) as b

where a.id=b.id and a.date=b.date ;

quit;

Thanks,

Jag

Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

Please try

proc sort data=have;

by id date;

run;

data want;

set have;

by id date;

if last.id;

run;

Thanks,

Jag

Thanks,
Jag
Jagadishkatam
Amethyst | Level 16

Also try the sql method

proc sql;

create table want as select a.* from have as a, (select max(date) as date, id from have group by id) as b

where a.id=b.id and a.date=b.date ;

quit;

Thanks,

Jag

Thanks,
Jag

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 860 views
  • 0 likes
  • 2 in conversation