BookmarkSubscribeRSS Feed
Whitepepper
Calcite | Level 5

Dear community, 

 

I have trouble when I try to write code for rolling window regression for a company. I need to get the estimate for each company within a rolling window of 60-month. I searched for the belowing solution, but it ignores different companies. For example, the last observations of first company A will be computed into the second company B. 

What I NEED is for each company, the rolling window regression is computed from the beginning. 

 

Could you please help me to solve this issue, I need improvement for the code. Let the code tell different company when it goes through the rolling window. 

 

Best regards!!!!!!!!!!!!

 

 

DATA rwin / view=rwin;

ws = 60;
nwin = nrecs - ws +1;
do w=1 to nwin;
do p=w to w + ws -1;
set part1 point=p nobs=nrecs;
output;
end;
end;

run;

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Go to your favorite interent search engine, type in 

 

rolling window regression in sas

 

and you will find lots of code that has already been written for this problem.

--
Paige Miller
Whitepepper
Calcite | Level 5

Dear PaigeMiller,

 

Thanks for your information. However, I really cannot find anything solving the different companies issue. 

 

Best regards

PaigeMiller
Diamond | Level 26

Seems like the other thread on this topic, which you posted in, contains specific code to do this. But I also see a Google search contains other links which also have code for the multiple company part of the problem.

--
Paige Miller

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 533 views
  • 0 likes
  • 2 in conversation