ESM Procedure

Example 14.1 Forecasting of Time Series Data

(View the complete code for this example.)

This example uses retail sales data to illustrate how the ESM procedure can be used to forecast time series data.

The following DATA step creates a data set from data recorded monthly at numerous points of sale. The data set, SALES, contains a variable, DATE, that represents time and a variable for each sales item. Each value of the DATE variable is recorded in ascending order, and the values of each of the other variables represent a single time series:

data sales;
   format date date9.;
   input date : date9. shoes socks laces dresses
                       coats shirts ties belts hats blouses;
   datalines;
01JAN1994 3557 3718 6368.80 575  987 10.8200 15.0000 102.600 12410 15013

   ... more lines ...   

The following ESM procedure statements forecast each of the monthly time series:

proc esm data=sales out=nextyear;
   id date interval=month;
   forecast _numeric_;
run;

The preceding statements generate forecasts for every numeric variable in the input data set SALES for the next 12 months and store these forecasts in the output data set NEXTYEAR.

The following statements plot the forecasts:

title1 "Shoe Department Sales";
proc sgplot data=nextyear;
   series x=date y=shoes / markers
                           markerattrs=(symbol=circlefilled color=red)
                           lineattrs=(color=red);
   series x=date y=socks / markers
                           markerattrs=(symbol=asterisk color=blue)
                           lineattrs=(color=blue);
   series x=date y=laces / markers
                           markerattrs=(symbol=circle color=styg)
                          lineattrs=(color=styg);
   refline '01JAN1999'd / axis=x;
   xaxis values=('01JAN1994'd to '01DEC2000'd by year);
   yaxis values=(2000 to 10000 by 1000) minor label='Websites';
run;

The plots are shown in Output 14.1.1. The historical data are shown to the left of the reference line, and the forecasts for the next 12 monthly periods are shown to the right.

Output 14.1.1: Retail Sales Forecast Plots

Retail Sales Forecast Plots


The default simple exponential smoothing model is used because the MODEL= option is omitted from the FORECAST statement. Note that for simple exponential smoothing the forecasts are constant.

The following ESM procedure statements are identical to the preceding statements except that the PRINT=FORECASTS option is specified:

proc esm data=sales out=nextyear print=forecasts;
   id date interval=month;
   forecast _numeric_;
run;

In addition to forecasting each of the monthly time series, the preceding statements print the forecasts by using the Output Delivery System (ODS); the forecasts are partially shown in Output 14.1.2. This output shows the predictions, prediction standard errors, and upper and lower confidence limits for the next 12 monthly periods.

Output 14.1.2: Forecast Tables

Shoe Department Sales

The ESM Procedure

Forecasts for Variable shoes
ObsTimeForecastsStandard Error95% Confidence Limits
62FEB19996009.19861069.40593913.20168105.1956
63MAR19996009.19861075.78463900.69968117.6976
64APR19996009.19861082.12573888.27138130.1259
65MAY19996009.19861088.42983875.91548142.4818
66JUN19996009.19861094.69763863.63068154.7666
67JUL19996009.19861100.92983851.41588166.9814
68AUG19996009.19861107.12693839.26988179.1274
69SEP19996009.19861113.28953827.19148191.2058
70OCT19996009.19861119.41813815.17948203.2178
71NOV19996009.19861125.51343803.23298215.1643
72DEC19996009.19861131.57583791.35078227.0465
73JAN20006009.19861137.60603779.53188238.8654


Last updated: June 19, 2025