Resources

Forecasting of Time Series Data

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: esmex01.sas
 Description: Example program from SAS/ETS User's Guide,
              The ESM Procedure
       Title: Forecasting of Time Series Data
     Product: SAS/ETS Software
        Keys: Exponential Smoothing Models
        PROC: ESM
       Notes:

--------------------------------------------------------------*/

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
01FEB1994  5128   4174   8123.20    565   1000   12.1200   15.1000    99.900   13556   12413
01MAR1994  5222   4482   7807.20    406   1005   11.7800   15.3000   102.000   11063   12752
01APR1994  3925   4665   7543.20    266   1043   12.2400   11.3000    79.500   11799   16222
01MAY1994  2750   4759   7242.00    194   1074   13.4600   14.7000    96.000   14497   13622
01JUN1994  5117   4469   6486.80    290   1042   12.4900   13.4000    98.000   14999   13193
01JUL1994  5570   4497   5654.30    583   1110   14.1400   21.8000   104.800   15711   17201
01AUG1994  3812   4103   6584.50    625   1054   14.2800   19.0000   107.500   12584    9455
01SEP1994  5917   4076   5635.20    654   1086   13.4200   19.1000   115.700   13036   11649
01OCT1994  5575   3801   7567.10    583   1054   14.4100   17.3000   113.200   15307   15269
01NOV1994  5301   3562   6670.10    643   1022   13.9200    6.6000    49.100   14136   10703
01DEC1994  4991   4025   6311.10    625   1022   14.3800   11.1000    60.200   14060   10623
01JAN1995  5014   4100   7986.60    649   1052   14.4300   16.4000    95.100   13495   14171
01FEB1995  5907   4472   8959.20    624   1066   13.8700   17.5000   112.200   14160   11414
01MAR1995  5954   4673   8414.20    524   1076   12.9300   16.9000   117.900   13225   12325
01APR1995  3854   4820   8415.40    352   1067   14.6200   12.2000    84.900   14755   15902
01MAY1995  3195   4988   8335.50    240   1109   13.9300   16.5000   112.700   15687   13305
01JUN1995  4714   4485   7667.20    336   1015   13.8300   13.3000   105.900   15865   13424
01JUL1995  5363   4742   5895.30    483   1151   15.4100   17.0000   121.100   18178   18838
01AUG1995  4094   4331   7458.20    642   1108   15.0600   16.8000   114.700   15403   10390
01SEP1995  5993   4127   7938.50    700   1128   15.4800   16.7000   127.400   16268   12780
01OCT1995  5331   3963   9087.10    610   1097   14.9200   16.0000   126.200   15942   17524
01NOV1995  6257   3814   6065.70    647   1096   15.0900   15.6000    75.700   14710   13328
01DEC1995  6300   4143   7215.90    668   1114   16.5700   14.4000    39.200   15286   13049
01JAN1996  4859   4102   8788.00    637   1054   15.8600    9.8000    93.300   14887   17036
01FEB1996  6009   4761   8225.70    572   1121   16.9000   16.1000   128.700   14537   14738
01MAR1996  5865   4952   7771.90    476   1089   17.4800   17.1000   115.800   14993   15529
01APR1996  3658   5012   7525.20    249   1067   19.4900   17.6000    66.900   15606   19901
01MAY1996  3161   5039   8327.30    250   1398   18.4700   18.1000   118.200   17758   15086
01JUN1996  4698   4570   7436.20    413   1081   17.5400   16.7000   107.100   18560   17221
01JUL1996  4530   4709   5737.60    616   1176   19.1500   12.9000   112.000   19497   23195
01AUG1996  3306   4435   7666.50    676   1164   19.7800   17.1000   109.600   15940   12999
01SEP1996  6291   4418   7321.10    684   1134   21.4300   17.0000   116.200   16466   15828
01OCT1996  5930   4217   8003.20    580   1110   21.2600   15.8000    99.600   19717   22800
01NOV1996  6613   4018   6161.30    679   1091   21.4700    3.6000    64.600   18769   15402
01DEC1996  5239   4307   5388.90    636   1118   22.9300    3.1000    60.000   20043   18266
01JAN1997  5952   4476   6707.80    619   1112   21.0400    2.9000    87.900   18055   22372
01FEB1997  7046   5032   7860.80    567   1176   22.6700    0.5000   112.100   17103   19721
01MAR1997  5928   5270   8214.90    438   1156   22.3100    3.7000   108.100   15858   18434
01APR1997  4875   5406   8055.60    277   1152   23.7000   15.1000    70.100   17592   23590
01MAY1997  4630   5578   7533.10    232   1241   22.6800   17.7000    64.700   20076   19490
01JUN1997  6514   5082   7257.30    292   1141   20.5900   15.5000    77.200   19574   18744
01JUL1997  5470   5171   5501.50    491   1244   22.7100   15.3000    96.600   22944   24860
01AUG1997  5984   4753   7100.70    579   1224   21.9900   16.0000   102.200   18059   12778
01SEP1997  6568   4540   6413.10    590   1230   23.0500   15.0000    96.300   18871   16452
01OCT1997  5353   4440   7373.70    547   1140   21.7900    9.8000    93.800   22315   25160
01NOV1997  4846   4342   6579.30    577   1150   22.3000   16.0000    63.600   20114   16337
01DEC1997  3614   4551   6046.20    548   1196   21.3000    3.8000    66.900   18995   18278
01JAN1998  4691   4747   7249.80    555   1172   21.6000   14.8000    92.200   17996   22451
01FEB1998  7478   5116   8594.40    538   1209   21.7000   14.2000   109.600   18548   18805
01MAR1998  6738   5794   8242.90    426   1175   20.7000   14.7000    99.800   16905   19275
01APR1998  4990   5674   8006.00    303   1203   20.5000   18.7000    82.000   17869   26609
01MAY1998  4262   5747   8719.90    190   1227   20.8000   17.6000    98.900   21946   21234
01JUN1998  6399   5401   7443.80    256   1182   19.7000   16.2000    95.100   21751   22179
01JUL1998  6790   5571   7053.20    447   1281   21.4000   17.1000   113.300   24539   29380
01AUG1998  5859   4966   8802.50    597   1228   20.5000   16.0000   109.600   20985   16242
01SEP1998  6594   4811   7570.20    648   1243   21.0000   16.0000   103.700   25837   20017
01OCT1998  7083   4668   9729.80    575   1149   20.6000   16.3000   119.900   24665   28459
01NOV1998  6870   4402   6576.20    619   1196   21.2000   12.1000    41.100   22842   23251
01DEC1998  5399   4795   6075.30    614   1239   21.2000    1.9000    79.700   23004   22044
01JAN1999  6405   4981   6812.10    607   1196   20.7000   14.9000    99.900   20583   26093
;
 
proc esm data=sales out=nextyear;
   id date interval=month;
   forecast _numeric_;
run;
 
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;
 
proc esm data=sales out=nextyear print=forecasts;
   id date interval=month;
   forecast _numeric_;
run;