FOCUS AREAS

Forecast Command Builder

The Forecast Command Builder is a SAS/AF application shipped with the Time Series Forecasting System (TSFS) in Version 7.01 and later. It contains a number of enhancements in release 8.2. See the prior documentation if you are using an earlier release.

The command builder lets you construct lists of forecast commands quickly, run them to create forecasts, save them, and retrieve them later for updating your forecasts. It's most common use is to set up and update batch forecast runs, which may contain hundreds or even thousands of related or unrelated time series. You can let the system choose forecasting models automatically, or develop models interactively using TSFS, save them in forecasting projects, and use the command builder to set up batch runs to update and output the forecasts. You can also start with the command builder to model and forecast a large number of series, then examine or modify individual forecasts in detail at a later time by opening the saved projects in TSFS.

The command builder also provides batch graphics features. Use these to create and save forecast graphs, either in a SAS catalog or in a web page. The web page format provides examples of each graph.

Start the command builder by entering on the command line (not the program editor):

    %fcb
or
    af c=sashelp.forcast.forccmd.frame

The command builder is also intended to serve as a demo application for developing custom forecasting interfaces using SAS/AF software. The frame entries are forccmd.frame, forccout.frame, forcgraf.frame, and forccgrf.frame. They are found in the sashelp.forcast catalog which ships with SAS/ETS software. You can download the SCL source code: forccmd.scl, forccout.scl, forcgraf.scl, forccgrf.scl, and forcmtd.scl.

Input tab

 Forecast command builder input tab
Forecast command builder Input tab

Begin by specifying a data source on the Input tab. This can be a SAS table or any other data source in your enterprise which has been made accessible, provided it is in time series form. This means that

If the data are not in time series form, an error message to this effect will appear in the SAS log when you run the command, and forecasts will not be generated. For more information, see "Working with Time Series Data" in the Online Documentation or SAS/ETS User's Guide.

If the data set contains a time ID variable named date, time, or datetime, the Time ID field will be filled in automatically. If not, specify the name of the time ID variable. If the data are in time series form but do not contain a time ID variable, you can run TSFS and use it's built-in tools to create one.

Normally, the system will detect the interval once the time ID variable is known and will fill in the interval field automatically. If it does not, your data may not be in proper time series form. However, if your data has an unusual interval, you can specify it using the interval Select button.

Once a time series data set has been selected, you can click the Select button to bring up the Series Selector. Use it to select one or more series to forecast.

As you make selections, a command is built and displayed in the Current Command box. If you only want to forecast a single series, you can execute the command by clicking the Run Current button. After execution, the command builder window remains open.

To build a list of commands, click the Add Current button. The current command is added to the list in the Command List tab. If you selected more than one series in the Series Selector, you will see "<multiple>" in the VAR= argument of the current command. When you click the Add Current button, a separate command is generated for each series selected, each having the respective series name substituted in the VAR= argument. The window fields remain populated until you select a different data set. You can add as many commands as you like to the command list, using as many different data sets as you like.

Model tab

 Forecast command builder model tab
Forecast command builder Model tab

This tab contains options governing the forecast model. All options have defaults and can be omitted.
Use series diagnostics
This option is on by default, and indicates that automatic model selection will fit only those models which are appropriate for the series according to the diagnostic criteria for log tranform, trend, and seasonality. If you turn off this option, DIAG=NO is added to the command and the system will attempt to fit all models in the model list.
Model fit criterion
This is the goodness-of-fit statistic which is used to select the best fitting forecasting model. If not specified, the default is Root Mean Square Error.
Models to keep
Specifies a number n such that the best n models will be retained in the project by the automatic fitting process. If omitted, only the best model is retained.
Refit options
Applies to an existing project which already contains a forecasting model for a given series. Reevaluate specifies that previous parameter estimates will be used but that fit statistics and forecasts will be recomputed from current data and the forecasting horizon will be adjusted if the data range has changed. Refit is similar except that the model parameters are also reestimated from current data. Be sure to check either Reevaluate or Refit if you want to update previous forecasts using revised data.

Forecast tab

 Forecast command builder forecast tab
Forecast command builder Forecast tab

All options have defaults and can be omitted.
Periods to forecast
Specifies the forecasting horizon, or number of periods to forecast. The default is 12.
Confidence limits
Specifies the width of the confidence limits computed for the forecast. Select a value from the popup menu, or type in a value without a decimal point. For example, 90 indicates 90% confidence limits. The default is 95.
Output data set
Specifies a two-level name (libname.memname) of a SAS data set to contain the forecasts and related results. If the data set does not already exist, it will be created. If a one-level name is provided, it is treated as a member in the WORK library.

Other tab

 Forecast command builder other tab
Forecast command builder Other tab

Entry
Defaults to FORECAST, which means that forecasts will be produced in unattended mode. Other entry points can be specified for other purposes. See Forecast command for details.
Project
To use an existing project, select it using the Browse button or type in its name. To create a new project, specify a new project name or omit it to use the default project name. Use an existing project if you want to set up options in advance which cannot be specified through the Forecast command, if you want to set up a custom model list which is specific to the project, or if you want to fit models interactively which will be reused or refit when the project is accessed by the Forecast Command Builder application (see also Refit options above).
Audit trail
Produces an audit trail in the SAS log, which provides more detail on the model fitting and forecasting process than is otherwise shown in the log.

Command List tab

 Forecast command builder Command List tab
Forecast command builder Command List tab

This tab displays all of the commands which have been added using the Add Current button or retrieved using the Open... button. You can edit any command in the list by clicking on it. It then becomes the current command and is editable using the other tabs. When you click Add Current, the revised command is added to the command list, but the original command remains in the list.

To execute all of the commands in the list, click the Run List button. Once the commands have been executed, control returns to the Forecast Command Builder window where you can revise your commands or click Close to close the application.

You can perform other tasks using the buttons on this tab:

Clear
Empties the command list.
Delete
Deletes the currently selected command from the list.
Open...
Invokes a dialog for loading a previously saved command list.
Save...
Invokes a dialog for saving your command list in a SAS catalog.

Graphics tab

 Forecast command builder Graphics tab
Forecast command builder Graphics tab

Use this tab to create forecast graphs for all your forecasts at once, placing the output in a framed web page or in a SAS catalog. Unlike the other tabs, this one does not add arguments to the Forecast command. It submits SAS/GRAPH statements to generate the graphs after all the forecast commands in the list have finished executing.

To use this feature, click the check box Create graphs for all forecasts. Graphs will be created as catalog entries in the SAS catalog specified under SAS/GRAPH output catalog. By default, this is work.gseg, which gets deleted at the end of your SAS session. If you want to keep the catalog, specify another name such as sasuser.graphs. This would create the catalog "graphs", if it does not already exist, under the libname "sasuser." If the catalog does exist, the system asks you if you want to overwrite it.

Each entry in the catalog will have the same name as the forecast data set being graphed, which is normally the same name as the time series. If the catalog already contains an entry of the same name, the system generates another entry with a numeric digit appended to the name. For example, suppose you are forecasting two series named Sales and Orders. The forecast data sets will also be named Sales and Orders, as will the two graphics catalog entries. However, if you previously created these graphs and they still exist, the new graphics entries will be named Sales1 and Orders1. If you don't want this to happen, click "yes" when asked whether to overwrite the existing graphics catalog, or use a new catalog name. The catalog entry names are limited to eight characters, so characters will be truncated from longer names.

Each graph has a title consisting of the series name. You can add additional text to the title by typing it into the Add to title item. Click the date and/or time check boxes if you want the title to include the date and/or time of the run.

By default, the date/time axis labels use the format assigned to the time ID variable in the data set. If there is no format assigned, or if the labels take up too much room on the graph, you can use the Select button to select a format. Use the most compact format possible for the best looking graph. For example, if you want a tick mark at yearly intervals, use the year2. format.

To place the graphs in web pages for viewing over the Internet or your intranet, click the Place graphs in web page check box. You must also specify a directory to which you have write-access under HTML directory. After the run is complete, you can access the graphs via index.html in the specified directory--see example.

Tips for batch runs

When you select a series, or click Add Current when multiple series have been selected, the Forecast Command Builder assigns output data sets with the same names as the series. That is, the OUT= name in each command is the same as the VAR= name. This makes it easy to identify the series represented by each output data set. You can change this by entering a different output data set name after making series selections. However, each command should have a unique output data set name, to prevent output from one series from being overwritten by that of another series.

The application also assigns project names (PROJ=) which are the same as the series names. You can change this by entering a different project name after making series selections. You can use the same project name for multiple commands if you want to be able to access all of your series subsequently through a single project. However, use distinct project names if the number of series becomes so large that you run out of memory.

The amount of time needed to complete the run depends on the number of commands and the amount of data. Since each command runs independently, the number of commands you can run in a batch is practically unlimited. Examine the SAS log for information about the outcome of your run.

For more detailed information and for examples, see the Forecast command documentation.

Viewing output

After commands have finished execution, if you have used the default entry option of FORECAST on the Other tab, the Forecast Command Builder brings up a Forecast Output selector window, as shown below. This window lists all the output data set names you specified in your commands. If you used the default output data set names, each name is the same as that of the series which were forecast. If errors occurred, some of these data sets may not exist, which is indicated by an asterisk next to the name.

 The forecast output selector window
The forecast output selector window

Select a forecast from the list to view it. Click the Table button to view the forecasts and supporting data in a Viewtable window. Click the Graph button to generate a graph of the selected forecast. By default, a new graph type is generated as shown below.

Plot of a selected output
Graph of the series selected in the Forecast Output window

This graph uses the AF Time Series Plot class and includes a toolbar and menus for zooming the graph, scrolling horizontally, querying the value of the point under the mouse cursor, changing the graph type, and printing. The classic graph type, using the AF Graphics class, is also available.

If you selected the Create graphs for all forecasts option on the graphics tab, the list of forecast output objects will also contain SAS/GRAPH output followed by a catalog name. You can select this object and click the Graph button to display all the forecast graphs in a SAS Graph window (this window may appear automatically).

If you also used the Place graphs in web page option, the list of output objects will contain HTML output <path> index.html, where <path> is the directory you specified. To display the web page using your Web browser, select this item in the output list and click the Graph button. The index.html file is a framed web page which displays a thumbnail of each forecast graph on the left. Clicking on a particular thumbnail opens a larger display of the selected forecast--see example. This format is ideal for distributing your forecasts graphically over the Internet or your intranet, and lets users get a quick picture of a large number of foreasts. Note that individual .html and .gif files are produced for each forecast in addition to the frame page named index.html.