BookmarkSubscribeRSS Feed
Werg
Calcite | Level 5
Hello folks, anyone know hot to use the eventby in hpfdignose? I'm in doubt about the layout of data. Thanks.
2 REPLIES 2
udo_sas
SAS Employee

Update: corrected "_" problem of the code below.

Hello -

This example might be useful.

Thanks,

Udo

data mymonthlydata(keep=t air);

    set sashelp.air;

    t = intnx( 'month', '01jan2004'd, _n_-1 );

run;

proc hpfevents data=mymonthlydata;

    var air;

    id t interval=month start='01jan2004'd end='31dec2014'd;

    eventkey AO11JAN2005D;

    eventdata out=myevents;

    eventdummy out=mydummydata;

run;

data mys1data(keep= t region store P1);

    length region store  $32;

    set mydummydata;

    region='R1';

    store='S1';

    P1 = air + 300*AO11JAN2005D ;

run;

data mys2data(keep= t region store P1);

    length region store  $32;

    set mydummydata;

      region='R1';

    store='S2';

    P1 = air + 300*AO11JAN2005D;

run;

data mys3data(keep= t region store P1);

    length region store  $32;

    set mydummydata;

    region='R2';

    store='S1';

    P1 = air;

run;

data mys4data(keep= t region store P1);

    length region store  $32;

    set mydummydata;

      region='R2';

    store='S2';

    P1 = air;

run;

data mysalesdata;

    set mys1data mys2data mys3data mys4data;

run;

data eventsby;

    length region store _NAME_ _EVENT_ _REQUIRED_ $32;

    region='R1';

    store='S1';

    _NAME_= 'P1';

    _EVENT_= 'AO11JAN2005D';

    _REQUIRED_= 'YES';

    output;

    region='R2';

    store='S1';

    _NAME_= 'P1';

    _EVENT_= 'AO11JAN2005D';

    _REQUIRED_= 'YES';

    output;

run;

ods select ARIMAEventSelect;

proc hpfdiagnose

    data=mysalesdata

    modelrepository=work.mymodels

    outest=inest

    inevent=myevents

    eventby=eventsby

    print=all;

    id t interval=month;

    forecast P1;

    by region store;

    arimax outlier=(detect=no);

run;

proc hpfengine

    data=mysalesdata

    plot=forecasts

    modelrepository=work.mymodels

    inest=inest

    inevent=myevents

    out=_null_ outfor=outfor1 outcomponent=outcomponent1;

    id t interval=month;

    forecast P1;

    by region store;

run;

Message was edited by: Udo Sglavo

Werg
Calcite | Level 5
It works!!!
Udo, thanks again!!!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 2 replies
  • 1901 views
  • 0 likes
  • 2 in conversation