To use PROC FORECAST, specify the input and output data sets and the number of periods to forecast in the PROC FORECAST statement, and then list the variables to forecast in a VAR statement.
For example, suppose you have monthly data on the sales of some product in a data set named PAST, as shown in Figure 16.1, and you want to forecast sales for the next 10 months.
Figure 16.1: Example Data Set PAST
Obs | date | sales |
---|---|---|
1 | JUL89 | 9.5161 |
2 | AUG89 | 9.6994 |
3 | SEP89 | 9.2644 |
4 | OCT89 | 9.6837 |
5 | NOV89 | 10.0784 |
6 | DEC89 | 9.9005 |
7 | JAN90 | 10.2375 |
8 | FEB90 | 10.6940 |
9 | MAR90 | 10.6290 |
10 | APR90 | 11.0332 |
11 | MAY90 | 11.0270 |
12 | JUN90 | 11.4165 |
13 | JUL90 | 11.2918 |
14 | AUG90 | 11.3475 |
15 | SEP90 | 11.2913 |
16 | OCT90 | 11.3771 |
17 | NOV90 | 11.5457 |
18 | DEC90 | 11.6433 |
19 | JAN91 | 11.9293 |
20 | FEB91 | 11.9752 |
21 | MAR91 | 11.9283 |
22 | APR91 | 11.8985 |
23 | MAY91 | 12.0419 |
24 | JUN91 | 12.3537 |
25 | JUL91 | 12.4546 |
The following statements forecast 10 observations for the variable SALES by using the default STEPAR method and write the results to the output data set PRED:
proc forecast data=past lead=10 out=pred; var sales; run;
The following statements use the PRINT procedure to print the data set PRED:
proc print data=pred; run;
The PROC PRINT listing of the forecast data set PRED is shown in Figure 16.2.
Figure 16.2: Forecast Data Set PRED
Obs | _TYPE_ | _LEAD_ | sales |
---|---|---|---|
1 | FORECAST | 1 | 12.6205 |
2 | FORECAST | 2 | 12.7665 |
3 | FORECAST | 3 | 12.9020 |
4 | FORECAST | 4 | 13.0322 |
5 | FORECAST | 5 | 13.1595 |
6 | FORECAST | 6 | 13.2854 |
7 | FORECAST | 7 | 13.4105 |
8 | FORECAST | 8 | 13.5351 |
9 | FORECAST | 9 | 13.6596 |
10 | FORECAST | 10 | 13.7840 |