Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Rewrite Macro rolling regression for output

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-22-2016 10:43 PM - edited 11-22-2016 10:44 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-22-2016 11:09 PM

you are missing a semicolon after r=resid

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-22-2016 11:15 PM

Thank you, I fixed it and there is no result, 0 observations and date 1,

date 2.

The old one, I got the results not in order of loop, they are mess up, I

dont know how to fix it.

##- Please type your reply above this line. Simple formatting, no

attachments. -##

date 2.

The old one, I got the results not in order of loop, they are mess up, I

dont know how to fix it.

##- Please type your reply above this line. Simple formatting, no

attachments. -##

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-22-2016 11:22 PM

Get the code working without any macros first. That will be a lot easier. Then transform back into macro coding.

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-23-2016 01:05 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-23-2016 10:45 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-24-2016 01:53 AM

Hi, you can use the link that I attached below. it can works well.

##- Please type your reply above this line. Simple formatting, no

attachments. -##

##- Please type your reply above this line. Simple formatting, no

attachments. -##