BookmarkSubscribeRSS Feed
pullasorsa
Calcite | Level 5

Hi all!

 

I am trying to do a rolling OLS regression with a data  that has variables YEAR, COMPANY_ID, Y, X1, X2 and X3. The data includes multiple companies (COMPANY_ID) for years 1995-2020 and different companies appear in the sample for different time periods.

 

The end result I am looking for is to have a table with regression coeficcient values for each regression time window. The simple OLS regression code for the first time window would be the following:

PROC REG DATA=MY_DATA;
MODEL Y=X1 X2 X3;
where 1995 <= YEAR <= 2000;
QUIT;

 

Do you know how I could include for example a loop into my code that would move the time period with one year after every run and save the coefficcient values to a table? I have found a lot of different macros for rolling regression but I have been unable to use them due to extremely limited knowledge on SAS. Thank you in advance for the help! 

1 REPLY 1

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 save with the early bird rate—just $795!

Register now

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 1 reply
  • 730 views
  • 0 likes
  • 2 in conversation