Hello all,
I am a new user of Sas but I have to try macro for rolling regression 12 months, shift one month forward. I did this one and it can run well for PROC REG with OUTEST. So I want to rewrite it for getting residual variable from OUTPUT, I tried many times and it is not working in every loop order. I did change one part like this:
proc reg data=&data;
where &date between &idate1 and &idate2;
model &model_equation;
&by_id;
output out=_outest_ds r=resid
run;
%* Add loop date range variables to output set;
data _outest_ds;
set _outest_ds;regobs= _p_ + _edf_; %* number of observations in regression; I delete this line because edf is from outest, but I changed it into OUTPUT and do not know how to count regressors.
date1= &idate1;
date2= &idate2;
%if &year_date=0 %then format date1 date2 date9.;
run;
THE CODE THAT I RUN FROM THE LINK BELOW and I can get the results of R-square correctly with rolling window 12 months.
http://www.lexjansen.com/nesug/nesug07/sa/sa04.pdf
I REALLY APPRECIATE YOUR HELP. I AM UNDER STRESSED NOW.
Nguyen
you are missing a semicolon after r=resid
Get the code working without any macros first. That will be a lot easier. Then transform back into macro coding.
Thank you, I did try it in simple form but the problem is rolling window for proc reg, I cannot create rolling loops because huge data. So I found this one and it works.
Hi,
What is the code that you used for PROC REG with OUTEST. I am struggling to run a rolling regression for my data as well. I referred to the same article that you did but I dint come up with the right code yet.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.