BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Benn
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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.

View solution in original post

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

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;

Haikuo
Onyx | Level 15

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 825 views
  • 3 likes
  • 3 in conversation