Forecasting using SAS Forecast Server, SAS/ETS, and more

Rid off from error message in proc forecast.

Reply
Regular Contributor
Posts: 161

Rid off from error message in proc forecast.

Hi all, below is simple example of proc forecast:

data pred;

      a=1;b=1;output;

      a=1;b=2;output;

      a=1;b=3;output;

      a=1;b=4;output;

      a=1;b=5;output;

      a=2;b=2;output;

      a=2;b=4;output;

      a=2;b=6;output;

      a=2;b=8;output;

      a=2;b=10;output;

run;

proc forecast data=pred lead=1 out=next(keep=a b);

      by a;

run;

Results is:

/*    a     b

      1     6

      2     12

*/

But if input data set has not enough records for analyze,proc forecast fails with error:Too few observations to fit model. At least 5 observations are required. Check your data.

data pred;

      a=1;b=1;output;

      a=1;b=2;output;

      a=1;b=3;output;

      a=1;b=4;output;

      a=1;b=5;output;

      a=2;b=2;output;

      a=2;b=4;output;

run;

proc forecast data=pred lead=1 out=next(keep=a b);

      by a;

run;

/* Results:

      1     6

ERROR: Too few observations to fit model. At least 5 observations are required. Check your data.

*/

So is it possible rid off(ommit) this error message? I mean  - if for small "by group" isn't enough rows for forecasting- ommit this row(without error message) and continue process next by groups.

I suppose 5 records can be also not enough in some cases.

Thanks!

Respected Advisor
Posts: 3,156

Re: Rid off from error message in proc forecast.

I believe it is hard to turn off error message completely (SAS would wonder why), "Warn" can sometimes be suppressed. In your case, this kind of error will NOT stop SAS from processing incoming data, so it won't "fail", per se. One way to limit the error message is to set:

MAXERRORS=

Again, you can't set it to '0', the minimum number you can set is '1'.

Haikuo

Regular Contributor
Posts: 161

Re: Rid off from error message in proc forecast.

Hello Haikuo,

Actually I tried this option before, and it didn't helped:

data pred;

      a=1;b=1;output;

      a=1;b=2;output;

      a=1;b=3;output;

      a=1;b=4;output;

      a=1;b=5;output;

      a=2;b=2;output;

      a=2;b=4;output;

run;

proc forecast data=pred lead=1 out=next(keep=a b) MAXERRORS=10;

      by a;

run;

If you'll try this code error will still occurs...

May be there some global option, smth. like noerrorstop in proc sql?

I should somehow eliminate these groups of data that are not ok for proc forecast...

Thanks!


Respected Advisor
Posts: 3,156

Re: Rid off from error message in proc forecast.

,

Like I said, MAXERRORS= will NOT eliminate your error message, but it will put a leash on it. Please look at the following example, try with/without commented option:

data pred;

do b=1 to 3;

a=1;output;

end;

do b=2 by 2 to 6;

a=2;output;

end;

do b=3 by 3 to 21;

a=3;output;

end;

run;

proc forecast data=pred lead=1 out=next(keep=a b) /*MAXERRORS=1*/ start=6;

  by a;

run;

With  " MAXERRORS=1 " in effect, you only get 1 error message; without, you get as many as it is supposed to be, here you will get 2. Bottom line, you will obtain your outcome table with those successfully processed data.

HTH,

Haikuo

Regular Contributor
Posts: 161

Re: Rid off from error message in proc forecast.

Hi Again,

Thanks, it's clear.

Anyway it will not fix the problem, maybe I'll just eliminate all groups that have less then 5 records and will hope that it(5 and more recs in group) will be enough for proc forecastSmiley Happy

Thanks!

Regular Contributor
Posts: 161

Re: Rid off from error message in proc forecast.

Hi again,

I've just checked -  and proc forecast really needs different min amount of input records for make forecasting, obviously depends on data...

Not nice but if there are no another solutions I think I should leave this macro code as it is and ignore the errors...

Anyway thanks!

Respected Advisor
Posts: 3,156

Re: Rid off from error message in proc forecast.

said: "I should somehow eliminate these groups of data that are not ok for proc forecast.."

Try this code to clean up your data, say '5' is the entry threshold:

Proc sql;

  create table want as

     select * from have group by a having count(*)>=5;quit;

Haikuo

Regular Contributor
Posts: 161

Re: Rid off from error message in proc forecast.

Hi again,

Yes yes, initially I also thougt about this , but as I remember I saw cases were even 6 records were not enough for proc forecast, I'm not sure about this , I use this proc just a few hours, so I will chack it one more time...

Thansk!

SAS Employee
Posts: 416

Re: Rid off from error message in proc forecast.

Hello -

You may try the following:

data pred;

      a=1;b=1;output;

      a=1;b=2;output;

      a=1;b=3;output;

      a=1;b=4;output;

      a=1;b=5;output;

      a=2;b=2;output;

      a=2;b=4;output;

run;

proc esm data=pred lead=1 out=next;

      forecast b / method=linear;

      by a;

run;

A couple of notes:

  • ESM runs exponential smoothing models with optimized parameters. Given your example a linear (Holt) exponential smoothing model seems to make sense, but the question remains if this is always the case (is a linear ESM always appropriate?).
  • The FORECAST procedure will apply the STEPAR Algorithm by default - its data requirements are described here: http://support.sas.com/documentation/cdl/en/etsug/63939/HTML/default/viewer.htm#etsug_forecast_sect0...
  • If you have only a few observations (like 2 in your example) available any forecasting technique becomes questionable of course. Maybe you are more concerned about fitting a linear regression line to your data and then extrapolate it to include new observations? In this case you are better off using the REG procedure of course. The question is if your data is autocorrelated.

Thanks,

Udo

Regular Contributor
Posts: 161

Re: Rid off from error message in proc forecast.

Hi Udo,

I believe that ESM procedures can be solution in my case, but my SAS version SAS 9.1.3 and due my licence I haven't ESM procedure...

But all your three notes make sence, Yestarday I used forecast procedure only first time and was very pleasent surprise with forecast values that it provides, but you are right, first of all I should try add as many observation to input algorithm as possible, then I should choose corrrect algorithm etc.

Thanks!

Ask a Question
Discussion stats
  • 9 replies
  • 958 views
  • 6 likes
  • 3 in conversation