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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

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