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!
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
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!
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
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 forecast:)
Thanks!
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!
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!
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:
Thanks,
Udo
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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.