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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.