Chapter Contents Previous Next
 The FORECAST Procedure

## Example 12.1: Forecasting Auto Sales

This example uses the Winters method to forecast the monthly U.S. sales of passenger cars series (VEHICLES) from the data set SASHELP.USECON. These data are taken from Business Statistics, published by the U.S. Bureau of Economic Analysis.

The following statements plot the series; the plot is shown in Output 12.1.1:

```
title1 "Sales of Passenger Cars";

symbol1 i=spline v=dot;
axis2 label=(a=-90 r=90 "Vehicles and Parts" )
order=(6000 to 24000 by 3000) ;
proc gplot data=sashelp.usecon;
plot vehicles * date = 1 /
haxis= '1jan80'd to '1jan92'd by year
vaxis=axis2;
where date >= '1jan80'd;
format date year4.;
run;
```

Output 12.1.1: Monthly Passenger Car Sales

The following statements produce the forecast:

```
proc forecast data=sashelp.usecon interval=month
out=out outfull outresid outest=est;
id date;
var vehicles;
where date >= '1jan80'd;
run;
```

The INTERVAL=MONTH option indicates that the data are monthly, and the ID DATE statement gives the dating variable. The METHOD=WINTERS specifies the Winters smoothing method. The LEAD=12 option forecasts 12 months ahead. The OUT=OUT option specifies the output data set, while the OUTFULL and OUTRESID options include in the OUT= data set the predicted and residual values for the historical period and the confidence limits for the forecast period. The OUTEST= option stores various statistics in an output data set. The WHERE statement is used to include only data from 1980 on.

The following statements print the OUT= data set:

```
title2 'The OUT= Data Set';
proc print data=out;
run;
```

The listing of the output data set produced by PROC PRINT is shown in part in Output 12.1.2.

Output 12.1.2: The OUT= Data Set Produced by PROC FORECAST

 Sales of Passenger Cars The OUT= Data Set

 Obs DATE _TYPE_ _LEAD_ VEHICLES 421 SEP91 ACTUAL 0 20827.00 422 SEP91 FORECAST 0 18266.20 423 SEP91 RESIDUAL 0 2560.79 424 OCT91 ACTUAL 0 23388.00 425 OCT91 FORECAST 0 19913.88 426 OCT91 RESIDUAL 0 3474.11 427 NOV91 ACTUAL 0 20181.00 428 NOV91 FORECAST 0 18294.58 429 NOV91 RESIDUAL 0 1886.41 430 DEC91 ACTUAL 0 14344.00 431 DEC91 FORECAST 0 15172.36 432 DEC91 RESIDUAL 0 -828.36 433 JAN92 FORECAST 1 16555.17 434 JAN92 L95 1 13514.26 435 JAN92 U95 1 19596.08 436 FEB92 FORECAST 2 19516.83 437 FEB92 L95 2 15908.52 438 FEB92 U95 2 23125.16 439 MAR92 FORECAST 3 19607.89 440 MAR92 L95 3 15954.55 441 MAR92 U95 3 23261.22

The following statements print the OUTEST= data set:

```
title2 'The OUTEST= Data Set: WINTERS Method';
proc print data=est;
run;
```

The PROC PRINT listing of the OUTEST= data set is shown in Output 12.1.3.

Output 12.1.3: The OUTEST= Data Set Produced by PROC FORECAST

 Sales of Passenger Cars The OUTEST= Data Set: WINTERS Method

 Obs _TYPE_ DATE VEHICLES 1 N DEC91 144 2 NRESID DEC91 144 3 DF DEC91 130 4 WEIGHT1 DEC91 0.1055728 5 WEIGHT2 DEC91 0.1055728 6 WEIGHT3 DEC91 0.25 7 SIGMA DEC91 1741.481 8 CONSTANT DEC91 18577.368 9 LINEAR DEC91 4.804732 10 S_JAN DEC91 0.8909173 11 S_FEB DEC91 1.0500278 12 S_MAR DEC91 1.0546539 13 S_APR DEC91 1.074955 14 S_MAY DEC91 1.1166121 15 S_JUN DEC91 1.1012972 16 S_JUL DEC91 0.7418297 17 S_AUG DEC91 0.9633888 18 S_SEP DEC91 1.051159 19 S_OCT DEC91 1.1399126 20 S_NOV DEC91 1.0132126 21 S_DEC DEC91 0.802034 22 SST DEC91 2.63312E9 23 SSE DEC91 394258270 24 MSE DEC91 3032755.9 25 RMSE DEC91 1741.481 26 MAPE DEC91 9.4800217 27 MPE DEC91 -1.049956 28 MAE DEC91 1306.8534 29 ME DEC91 -42.95376 30 RSQUARE DEC91 0.8502696

The following statements plot the residuals. The plot is shown in Output 12.1.4.

```
title2 'Plot of Residuals';
symbol1 i=needle;
axis2 label=( a=-90 r=90 "Vehicles and Parts" );
proc gplot data=out;
plot vehicles * date = 1 / vref=0
haxis= '1jan80'd to '1jan92'd by year
vaxis=axis2;
where _type_ = 'RESIDUAL';
format date year4.;
run;
```

Output 12.1.4: Residuals from Winters Method

The following statements plot the forecast and confidence limits. The last two years of historical data are included in the plot to provide context for the forecast plot. A reference line is drawn at the start of the forecast period.

```
title2 'Plot of Forecast from WINTERS Method';
symbol1 i=none   v=star; /* for _type_=ACTUAL */
symbol2 i=spline v=circle; /* for _type_=FORECAST */
symbol3 i=spline l=3;        /* for _type_=L95 */
symbol4 i=spline l=3;        /* for _type_=U95 */
axis2 label=( a=-90 r=90 "Vehicles and Parts" )
order=(6000 to 24000 by 3000) ;

proc gplot data=out;
plot vehicles * date = _type_ /
HREF='15dec91'd
haxis= '1jan90'd to '1jan93'd by qtr
vaxis=axis2;
where _type_ ^= 'RESIDUAL' & date >= '1jan90'd;
run;
```

The plot is shown in Output 12.1.5.

Output 12.1.5: Forecast of Passenger Car Sales

 Chapter Contents Previous Next Top