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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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