BookmarkSubscribeRSS Feed
Calcite | Level 5

Hello All


Im trying to use PROC HPFENGINE and the STOCHASTIC option for a bunch of inputs on various promotions for a CPG customer - using test data first....


I cant even get to the STOCHASTIC option yet as Im trying to just run a forecast and seem to be getting stuck with the errors stating my observations are too few....


any ideas??  Ultimately I want to run the promo fields as independent factors and I will not have future promo info but have never applied the STOCHASTIC option also - I guess trying to get the PROC to run first then tackle the option!




Attaching data and code and log

Tourmaline | Level 20
Quartz | Level 8

where is the link to "forecasting community"?




Opal | Level 21

@t75wez1  - You are responding to a post IN the Forecasting Community so you are already there...😉

SAS Employee


If you are new to programming with Forecast Studio procedures, I would recommend that you use the Forecast Studio UI first. It enables you to generate forecasts with only a few clicks. Then look at the generated code as an example. 


To your specific question, I am guessing you want to forecast more than one series, i.e. separate your series using BY groups. Try the following code.

proc sort data=download.nestle_sorted;
  by province_name brand date;

proc hpfengine data = download.nestle_sorted outfor=forecasts;
  id date interval=week accumulate=total notsorted;
  by province_name brand;
  forecast net_revenue;

proc print data=forecasts(obs=20);

Note that there are several missing values in your dependent variable even at this fairly aggregated level, and several series have one observation only. Your forecasts are only as good as your input data. You can't forecast where there is not sufficient data. You may want to change your interval to month or address the missing data in some other way. 

I would also recommend that you use HPFDIAGNOSE before using HPFENGINE. 


Finally, these seem proprietary data. It may be a good idea to mask them before posting them on a public forum. 


Calcite | Level 5

Thank you for your advice - the code adjustment worked and I have a baseline forecast now!


Attached is the code, Log, and sample output


i just now need to invoke the STOCHASTIC option to forecast future promo that do not exist....there are several independent promo variables (0 or 1) in the history but the customer wants to forecast future promos.


Here is some more background for this:


Typically a forecast is generated of independent variables (historic promotions) which is used to score the dependent variable. Instead of using the esm forecast of the promotion, we replace the future values with user defined future planned promotions.


Any further help is greatly appreciated!


BTW - this data is completely fake with realistic labels......just used for testing until we get real data.





Calcite | Level 5

Hello Again Experts,


I wanted to add more clarity and context around my last note.  The goal of the customer is not only create a forecast based on historical independent factors like promotion binary variables (0 or 1) to forecast bet revenue in the future - BUT also, and perhaps more importantly, to forecast which promotions are significant and the timing (when to offer which ones) across levels of the hierarchy (Province, Type, Brand).


I was speaking with a colleague and she alerted me to this critical piece around timing of the promotions in addition to which ones to offer.


Thanks for your time!

SAS Employee

The models that HPFENGINE supports are designed for real-values time series. They are unsuited for forecasting binary values such as promotions. You can use promotions as independent variables to assess their influence, but you won't be able to forecast them as time series (it doesn't make sense, they are control variables). You can, however, create scenarios to evaluate the effect of different promotions. You will need to provide the values of the promotions for the scenarios though.

Again, I would recommend you use Forecast Studio instead. It has an interface for scenario analysis. 

If you want to optimize the choice of your promotions you need to look at marketing optimization. A very short description is that it combines scenario analysis with an optimization process.






Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 7 replies
  • 5 in conversation