1

I was using proc een in SAS, for time series forecasting. I want to include two variables in by statement. My data contains four columns:

  1. Shop_id
  2. Item_id
  3. Item_price
  4. Date

The item_price column is the one which should be forecasted. The date is in months. I want to include both shop_id and item_id in the by statement

Is it possible ?

ebrahimi
  • 1,305
  • 7
  • 20
  • 40

1 Answers1

0

Yes, a BY statement can be used with PROC ESM to separate groups of observations defined by the BY variables.

According to the PROC ESM documentation, when a BY statement is used, the procedure expects the input data set to be sorted in order of the BY variables. In this case, I just use PROC SORT to sort the data before the PROC ESM with similar, BY statement.

It uses PROC ESM and SASHELP.PRICEDATA dataset (included) to plot forecasts grouped by region, line and product.

ods noproctitle;
ods graphics / imagemap=on;

proc sort data=SASHELP.PRICEDATA out=Work.preProcessedData; by regionName productLine productName date; run;

proc esm data=Work.preProcessedData plot=(modelforecasts); by regionName productLine productName; id date interval=Month; forecast sale; run;

In your case, you must change the variable names accordingly. In the end, you should end up with something like this:

ods noproctitle;
ods graphics / imagemap=on;

proc sort data=mydata out=Work.preProcessedData; by regionName shop_id item_id date; run;

proc esm data=Work.preProcessedData plot=(modelforecasts); by shop_id item_id ; id date interval=onth; forecast item_price; run;

Check out more info at SAS Help Center: BY Statement.

Cheers.