The FORECAST Procedure

Example 16.1 Forecasting Auto Sales

(View the complete code for this example.)

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 16.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);

title1 "Sales of Passenger Cars";
proc sgplot data=sashelp.usecon;
   series x=date y=vehicles / markers;
   xaxis values=('1jan80'd to '1jan92'd by year);
   yaxis values=(6000 to 24000 by 3000);
   format date year4.;
run;

Output 16.1.1: Monthly Passenger Car Sales

Monthly Passenger Car Sales


The following statements produce the forecast:

proc forecast data=sashelp.usecon interval=month
              method=winters seasons=month lead=12
              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 (first 20 observations):

title2 'The OUT= Data Set';
proc print data=out (obs=20) noobs;
run;

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

Output 16.1.2: The OUT= Data Set Produced by PROC FORECAST (First 20 Observations)

Sales of Passenger Cars
The OUT= Data Set

DATE_TYPE__LEAD_VEHICLES
JAN80ACTUAL08808.00
JAN80FORECAST08046.52
JAN80RESIDUAL0761.48
FEB80ACTUAL010054.00
FEB80FORECAST09284.31
FEB80RESIDUAL0769.69
MAR80ACTUAL09921.00
MAR80FORECAST010077.33
MAR80RESIDUAL0-156.33
APR80ACTUAL08850.00
APR80FORECAST09737.21
APR80RESIDUAL0-887.21
MAY80ACTUAL07780.00
MAY80FORECAST09335.24
MAY80RESIDUAL0-1555.24
JUN80ACTUAL07856.00
JUN80FORECAST09597.50
JUN80RESIDUAL0-1741.50
JUL80ACTUAL06102.00
JUL80FORECAST06833.16


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 16.1.3.

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

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

Obs_TYPE_DATEVEHICLES
1NDEC91144
2NRESIDDEC91144
3DFDEC91130
4WEIGHT1DEC910.1055728
5WEIGHT2DEC910.1055728
6WEIGHT3DEC910.25
7SIGMADEC911741.481
8CONSTANTDEC9118577.368
9LINEARDEC914.804732
10S_JANDEC910.8909173
11S_FEBDEC911.0500278
12S_MARDEC911.0546539
13S_APRDEC911.074955
14S_MAYDEC911.1166121
15S_JUNDEC911.1012972
16S_JULDEC910.7418297
17S_AUGDEC910.9633888
18S_SEPDEC911.051159
19S_OCTDEC911.1399126
20S_NOVDEC911.0132126
21S_DECDEC910.802034
22SSTDEC912.63312E9
23SSEDEC91394258270
24MSEDEC913032755.9
25RMSEDEC911741.481
26MAPEDEC919.4800217
27MPEDEC91-1.049956
28MAEDEC911306.8534
29MEDEC91-42.95376
30RSQUAREDEC910.8502696


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

title1 "Sales of Passenger Cars";
title2 'Plot of Residuals';
proc sgplot data=out;
   where _type_ = 'RESIDUAL';
   needle x=date y=vehicles / markers markerattrs=(symbol=circlefilled);
   xaxis values=('1jan80'd to '1jan92'd by year);
   format date year4.;
run;

Output 16.1.4: Residuals from Winters Method

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.

title1 "Sales of Passenger Cars";
title2 'Plot of Forecast from WINTERS Method';
proc sgplot data=out;
   series x=date y=vehicles / group=_type_ lineattrs=(pattern=1);
   where _type_ ^= 'RESIDUAL';
   refline '15dec91'd / axis=x;
   yaxis values=(9000 to 25000 by 1000);
   xaxis values=('1jan90'd to '1jan93'd by qtr);
run;

The plot is shown in Output 16.1.5.

Output 16.1.5: Forecast of Passenger Car Sales

Forecast of Passenger Car Sales