Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Command Reference

FORECAST command

The forecast command invokes the Time Series Forecasting System. The syntax is

FORECAST PROJECT= project name
DATA= dataset name
VAR= time series variable name
ID= time id variable name
INTERVAL= interval name
STAT= statistic
CLIMIT= integer
HORIZON= integer
ENTRY= name
OUT= dataset name
REFIT
REEVAL
If the forecast command is issued without arguments, the Time Series Forecasting window appears. This is equivalent to selecting Time Series Forecasting System from the Analysis submenu of the Solutions pull-down menu.

Using the arguments, it is possible to:



PROJECT= project name
Specifies the name of the SAS catalog entry in which forecasting models and other results will be stored and from which previously stored results are loaded into the forecasting system.

DATA= dataset name
Specifies the name of the SAS data set containing the input data.

VAR= time series variable name
Specifies the series variable name. A numeric variable contained in the data set.

ID= time id variable name
Specifies the time ID variable name for the data set. If the ID= option is not specified, the system will attempt to locate the variables named DATE, DATETIME, TIME in the data set specified by the DATA= option. However, it is recommended that you specify the time ID variable whenever you are using the ENTRY= argument.

INTERVAL= interval name
Specifies the time ID interval between observations in the data set. Commonly used intervals are year, semiyear, qtr, month, semimonth, week, weekday, day, hour, minute, and second. See Chapter 3, "Date Intervals, Formats, and Functions," for information on more complex interval specifications. If the INTERVAL= option is not specified, the system will attempt to determine the interval based on the time ID variable. However, it is recommended that you specify the interval whenever you are using the ENTRY= argument.

STAT= statistic
Specifies the name of the goodness-of-fit statistic to be used as the model selection criterion. The default is rmse. Valid names are:

sse
Sum of Square Error
mse
Mean Square Error
rmse
Root Mean Square Error
mae
Mean Absolute Error
mape
Mean Absolute Percent Error
aic
Akaike Information Criterion
sbc
Schwarz Bayesian Information Criterion
rsquare
R-Square
adjrsq
Adjusted R-Square
rwrsq
Random Walk R-Square
arsq
Amemiya's Adjusted R-Square
apc
Amemiya's Prediction Criterion

CLIMIT= integer
An integer specifying the level of the confidence limits to be computed for the forecast. This integer represents a percentage, e.g., 925 indicates 92.5% confidence limits. The default is 95, i.e., 95% confidence limits.

HORIZON= integer
Specifies the number of periods into the future for which forecasts will be computed. The default is 12 periods. The maximum is 9999.

ENTRY= name
The name of an entry point into the system. Valid names are:

main
Starts the system at the Time Series Forecasting Window (default).

devmod
Starts the system at the Develop Models Window.

viewmod
Starts the system at the Model Viewer Window. Specify a project containing a forecasting model using the PROJECT= option. If a project containing a model is not specified, the message "No forecasting model to view" appears.

viewser
Starts the system at Time Series Viewer Window.

autofit
Runs the system in unattended mode, fitting a forecasting model automatically and saving it in a project. If PROJECT= is not specified, the default project name SASUSER.FMSPROJ.PROJ is used.

forecast
Runs the system in unattended mode to generate a forecast data set. The name of this data set is specified by the OUT= parameter. If OUT= is not specified, a window appears to prompt for the name and label of the output data set. If PROJECT= is not specified, the default project name SASUSER.FMSPROJ.PROJ is used. If the project does not exist or does not contain a forecasting model for the specified series, automatic model fitting is performed and the forecast is computed using the automatically selected model. If the project exists and contains a forecasting model for the specified series, the forecast is computed using this model. If the series covers a different time range than it did when the project was created, use the REFIT or REEVAL keyword to reset the time ranges.

OUT= argument
The one or two-level name of a SAS data set in which forecasts will be saved. Use in conjunction with ENTRY=FORECAST. If omitted, the system prompts for the name of the forecast data set.

REFIT keyword
Refits a previously saved forecasting model using the current fit range, i.e., reestimates the model parameters. Refitting also causes the model to be reevaluated (statistics of fit recomputed), and causes the time ranges to be reset if the data range has changed, e.g., if new observations have been added to the series. This keyword has no effect if you do not use the PROJECT= argument to reference an existing project containing a forecasting model. Use the REFIT keyword if you have added new data to the input series and you want to refit the forecasting model and update the forecast using the new time ranges. Be sure to use the same project, data set, and series names that you used previously.

REEVAL keyword
Reevaluates a previously saved forecasting model using the current evaluation range, i.e., recomputes the statistics of fit. Reevaluating also causes the time ranges to be reset if the data range has changed, e.g., if new observations have been added to the series. It does not refit the model parameters. This keyword has no effect if you also specify REFIT, or if you do not use the PROJECT= argument to reference an existing project containing a forecasting model. Use the REEVAL keyword if you have added new data to the input series and want to update your forecast using a previously fit forecasting model and the same project, data set, and series names that you used previously.

Examples

The following command brings up the Time Series Forecasting window with the data set name and series name filled in. The time ID variable is also filled in since the data set contains the variable DATE. The interval is filled in because the system recognizes that the observations are monthly.


   forecast data=sashelp.air var=air

The following command brings up the Time Series Forecasting window with the project, data set name, series, time ID, and interval fields filled in, assuming that the project samproj was previously saved either interactively or using unattended mode as depicted below. Previously fit models will appear when the Develop Models or Manage Projects window is opened.


   forecast project=samproj

The following command runs the system in unattended mode, fitting a model automatically, storing it in the project "samproj" in the default catalog sasuser.fmsproj, and placing the forecasts in the data set work.sampout.


   forecast data=sashelp.workers var=electric id=date interval=month
   project=samproj entry=forecast out=sampout

The following command assumes that a new month's data have been added to the data set from the previous example and that an updated forecast is needed using the previously fit model. Time ranges are automatically updated to include the new data since the REEVAL keyword is included. Substitute REFIT for REEVAL if you want the system to reestimate the model parameters.

     
   forecast data=sashelp.workers var=electric id=date interval=month
   project=samproj entry=forecast out=sampout reeval

The following command brings up the model viewer using the project created in the previous example and using 99 percent confidence limits in the forecast graph.

     
   forecast data=sashelp.workers var=electric id=date interval=month
   project=samproj entry=viewmod climit=99

The final example illustrates using unattended mode with an existing project which has been defined interactively in order to set options which cannot be specified on the command line. In this example, the goal is to add a model to the model selection list, and to specify that all models in that list be fit and that all models which are fit successfully be retained.

First bring up the Time Series Forecasting Window and specify a new project name, workproj. Then select Develop Models, choosing sashelp.workers as the data set and masonry as the series. Now select Model Selection List from the Options pull-down menu. In the Model Selection List window, click Actions, then Add, then ARIMA Model. Define the model ARIMA(0,1,0)(0,1,0)s NOINT by setting the differencing value to 1 under both ARIMA Options and Seasonal ARIMA Options. Select OK to save the model and OK to close the Model Selection List window. Now select Automatic Fit from the Options pull-down. In the Automatic Model Selection Options window, select All autofit models in selection list in the Models to fit radio box, and select All models from the Models to keep combo box, then click OK to close the window. Select Save Project from the File pull-down menu, and then close the Develop Models window and the Time Series Forecasting window. You now have a project with a new model added to the selection list, options set for automatic model fitting, and one series selected but no models fit.

Now enter the command:

 
   forecast data=sashelp.workers var=electric id=date interval=month
   project=workproj entry=forecast out=workforc

The system runs in unattended mode to update the project and create the forecast data set workforc. Check the messages in the log window to find out if the run was successful and which model was fit. To see the forecast data set, issue the command viewtable workforc. To see the contents of the project, bring up the Time Series Forecasting Window, open the project workproj, and select Manage Projects. You will see that the variable electric was added to the project and has a forecasting model. Select this row in the table and then select List Models from the Tools pull-down menu. You will see that all of the models in the selection list which fit successfully are there, including the new model you added to the selection list.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.