Help using Base SAS procedures

How to get max date from entries

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

How to get max date from entries

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


Accepted Solutions
Solution
‎07-26-2015 03:19 AM
Trusted Advisor
Posts: 1,128

Re: How to get max date from entries

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


All Replies
Trusted Advisor
Posts: 1,128

Re: How to get max date from entries

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
Solution
‎07-26-2015 03:19 AM
Trusted Advisor
Posts: 1,128

Re: How to get max date from entries

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
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 257 views
  • 0 likes
  • 2 in conversation