turn on suggestions

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
- /
- Forecasting
- /
- Conversion of Eviews Forecast Program

Topic Options

- 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

06-26-2017 10:34 AM - edited 06-26-2017 10:34 AM

As a new SAS user I have leaned a lot from these forums. However, I am a bit stuck as to the conversion of an EViews model I created a few years back. It is designed to iterate a few thousand times and forecast based on the distribution of the variable under study and a random number (quasi random walk based on a variable's history and standard devlation). I am not sure how this would translate into a data step or a proc step (or both) within SAS. Some of the conversions will be easy, but some will not be. I will describe as I go. The EViews code:

```
!num_rnd_walk_f=8000
!starts_hold_rw_f=0
%forecast_start_rw="Apr2014"
%forecast_end_rw="Apr2015"
'Note that the RW depends on the previous value of the forecast, so we can only step forward one period at a time, placing the forecast in the right spot to be used
!loopsize = @dtoo(%forecast_end_rw) - @dtoo(%forecast_start_rw) 'This is the difference between the dates, the value will be 11 here and not 12 due to subtraction of the dates, so just start at 0 in the loop counter below. This will make 12 monthly forecasts
for !count1=0 to !loopsize
%loop_date = @otod(@dtoo(%forecast_start_rw) + !count1)
smpl %loop_date %loop_date 'Move forward 1 period at a time in your forecast so you will have a random walk forecast for the next period, as it is lagged in starts(-1)
for !count2=1 to !num_rnd_walk_f 'We can forecast many random walks per observation
starts_hold_rw_f=starts_hold_rw_f + @mean(d(starts),"1960 2014.1") + starts(-1) + @stdev(d(starts),"1960 2014.1")*nrnd
next
genr starts_f=@round(starts_hold_rw_f/!num_rnd_walk_f)
'Since starts(-1) is used in the RW formula, we need to place the forecast in there for next time...this will also make it easier to copy into the annual section as well
starts=starts_f
next
```

The first few declaratives are easy for SAS:

num_rnd_walk_f=8000;

starts_hold_rw_f=0;

forecast_start_rw='01Apr2014'd;

forecast_end_rw='01Apr2015'd;

With respect to the loopsize variable that comes next, can SAS subtract dates and get an integer? In this case loopsize=forecast_end_rw - forecast_start_rw and it should be 12, but it may be 11 due to the subtraction (not really and issue as can add one back to start the next loop at 0).

The problem for me is now in the loop section. Eviews will let me change the sample within the loop so the forecast period can be populated. It is used in EViews as:

%loop_date = @otod(@dtoo(%forecast_start_rw) + !count1) This just increments the forecast period

smpl %loop_date %loop_date

Perhaps the biggest challenge for me is the actual forecast generation:

starts_hold_rw_f=starts_hold_rw_f + @mean(d(starts),"1960 2014.1") + starts(-1) + @stdev(d(starts),"1960 2014.1")*nrnd

The above statement is looped for thousands of times and takes the previous forecast value, and adds to it the mean of the history of starts and adds the standard deviation of starts * a random number that comes from a normal distribution with zero mean and unit variance.

It then finds what the average forecast is over the user specified iterations by:

genr starts_f=@round(starts_hold_rw_f/!num_rnd_walk_f)

I am not sure exactly how this will translated into SAS, as it is not clear to me how to:

1. Change the sample period iterastively during the loop to populate the forecasts.

2. How to reference the mean and standard deviation of the series in question as EViews does.

3. What random number procedure in SAS would be most useful.

4. Or if there are easier "SAS Ways" to do this.

Thanks in advance, and for your patience.

-Bill