Hi Guys,
I am trying to compute monthly rolling averages and my dates are in the format YYYYMM.
Hope someone will be familiar with codes like this.
Thanks!
Without seeing some sample data, suggestions can't be specific:
1. If you have SAS/ETS, then Proc Expand is your best bet. Rolling Average is just one of its build-in functions.
2. If you choose to use Proc SQL like being suggested, 'group by' needs to be applied on an unique id of every row from t1.
3. Data step, by using temporary array, mod() and/or 'by' processing. Please search 'rolling' or 'moving' in the forum, you will see many posts with similar questions and answers.
Good luck,
Haikuo.
its useful to have sample data...but...3 month rolling average
proc sql;
create table want as
select
t1.dt
,avg(t2.....???) as monthly_rolling_avg
from
want t1
inner join want t2
t2.date between intnx('month',t1.date,-3) and t1.date
group by t1.dt;
quit;
Without seeing some sample data, suggestions can't be specific:
1. If you have SAS/ETS, then Proc Expand is your best bet. Rolling Average is just one of its build-in functions.
2. If you choose to use Proc SQL like being suggested, 'group by' needs to be applied on an unique id of every row from t1.
3. Data step, by using temporary array, mod() and/or 'by' processing. Please search 'rolling' or 'moving' in the forum, you will see many posts with similar questions and answers.
Good luck,
Haikuo.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.