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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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