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!
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.
your the man!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.