First step in almost anything involving dates is to ensure that you have an actual SAS date valued numeric variable. Then there are a slew of tools to work with.
Best is to share what your actual data set is like using a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
You need to show what your desired output looks like. It is not clear whether you want a data set, for further processing, or a report that people will read.
you mean something like
proc sql ;
select state, substr(yearmonth,1,4) as year, avg(Spend_Amt) as Avg_spend_amt
From table
group by state, substr(yearmonth,1,4);
Quit ;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.