BookmarkSubscribeRSS Feed
bssiders
Calcite | Level 5

I have a set of data where I want to find the max date per year.  Somewhat like this:

 

proc sql;

create table x as select

max(account_date) as last_day format date9.

from y

;quit;

 

However, the last date per year can vary so instead of grabbing the last date for the entire set, I want to subset by year.  The output would look something like this:

 

Year   MaxDate

2011   10OCT2011

2012   14NOV2012

2013   31DEC2013

2014   05JUL2014

2015   31DEC2015

.... and so on

 

There has to be a simple way with a few lines of code vs many.  Any help would be appreciated!

2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc summary data=have nway;
    class year;
    var account_date;
    output out=want max=maxdate;
run;

 

 

This assumes you already have a variable named YEAR, if you don't that's easily fixed. 

--
Paige Miller

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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