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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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