Resources

Specifying the Forecasting Model

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

                    SAS Sample Library

        Name: esmex03.sas
 Description: Example program from SAS/ETS User's Guide,
              The ESM Procedure
       Title: Specifying the Forecasting Model
     Product: SAS/ETS Software
        Keys: Exponential Smoothing Models
        PROC: ESM
       Notes:

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

data websites(label="Transactional Internet data");

   /*- time variable definition -*/
       keep time;
       format time datetime.;
       label time="Time of Webhit";
       starttime = '12mar2000:00:00:00'dt; /*- Sunday -*/
       seedtime = 1234321;

   /*- cars variable definition -*/
       keep cars;
       format cars best12.;
       label cars="Number of Car Webhits";
       seedcar = 1234321;

   /*- boats variable definition -*/
       keep boats;
       format boats best12.;
       label boats="Number of Boat Webhits";
       seedboat = 1234321;

   /*- planes variable definition -*/
       keep planes;
       format planes best12.;
       label planes="Number of Planes Webhits";
       seedplane = 1234321;

   /*- engines variable definition -*/
       keep engines;
       format engines best12.;
       label engines="Number of Engine Webhits";
       seedengine = 1234321;

   /*- simulate the data -*/
       do day = 1 to 30;
          season = abs(4 - mod(day,7));
          nhits = ceil(10*ranuni(seedtime));
          intv = 24*3600*ranuni(seedtime)/nhits;
          do hits = 1 to nhits;

          /*- randomly generate the next time -*/
              intv = intv + 24*3600*ranuni(seedtime)/nhits;
              intv = int(intv);
              time = intnx( 'DTDAY', starttime, day );
              time = intnx( 'DTSECOND', time, intv );

          /*- randomly generate car data -*/
               cars = 1000 + 600*day + 1000*season
                    + 10*rannor(seedcar);
               cars = int(cars);

          /*- randomly generate boats data -*/
              boats = 1000 + 1000*season +
                    + 10*rannor(seedboat);
              boats = int(boats);

          /*- randomly generate planes data -*/
              planes = 1000 - 10*day +
                     + 10*rannor(seedplane);
              planes = int(planes);

          /*- randomly generate engines data -*/
              engines = 1000 + 1*cars - 2*boats + 4*planes
                      + 10*rannor(seedengine);
              engines = int(engines);

             output;
         end;
      end;

run;

proc esm data=websites out=nextweek lead=7;
   id time interval=dtday accumulate=total;
   forecast boats   / model=seasonal;
   forecast cars    / model=multwinters;
   forecast planes  / model=addwinters transform=log;
run;