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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 413 views
  • 0 likes
  • 2 in conversation