Hello,
I'm trying to forecast the number of X and Y for each ID monthly for the next two years.
I have 6 months of data, my numbers are pretty much flat.
I'm not sure what forecast technique I should be using.
Thanks for your help in advance.
Date | ID | X | Y |
Jan-18 | A1 | 10 | 4 |
Jan-18 | B1 | 27 | 5 |
Jan-18 | C1 | 35 | 22 |
Jan-18 | D1 | 34 | 27 |
Jan-18 | F1 | 24 | 27 |
Feb-18 | A1 | 2 | 44 |
Feb-18 | B1 | 33 | 20 |
Feb-18 | C1 | 0 | 7 |
Feb-18 | D1 | 24 | 44 |
Feb-18 | F1 | 0 | 34 |
Mar-18 | A1 | 42 | 24 |
Mar-18 | B1 | 67 | 2 |
Mar-18 | C1 | 6 | 33 |
Mar-18 | D1 | 0 | 0 |
Mar-18 | F1 | 63 | 24 |
Mar-18 | L1 | 36 | 0 |
Since you do not have a long history of data, I suggest to calculate forecast values using a simple method like moving average. You can use PROC ARIMA with the options: noint noest and method=CLS. See the documentation at:
Assuming you have at least 6 months of data (since proc ARIMA needs at least 6 observations to perform identification step), you may use the following code:
data test; input date monyy7. ID$ X Y; format date monyy7.; datalines; JAN2018 A1 10 4 JAN2018 B1 27 5 JAN2018 C1 35 22 JAN2018 D1 34 27 JAN2018 F1 24 27 FEB2018 A1 2 44 FEB2018 B1 33 20 FEB2018 C1 0 7 FEB2018 D1 24 44 FEB2018 F1 0 34 MAR2018 A1 42 24 MAR2018 B1 67 2 MAR2018 C1 6 33 MAR2018 D1 0 0 MAR2018 F1 63 24 APR2018 A1 35 24 APR2018 B1 22 2 APR2018 C1 14 33 APR2018 D1 20 0 APR2018 F1 13 24 MAY2018 A1 21 24 MAY2018 B1 70 2 MAY2018 C1 60 33 MAY2018 D1 55 0 MAY2018 F1 55 24 JUN2018 A1 41 24 JUN2018 B1 64 2 JUN2018 C1 60 33 JUN2018 D1 10 0 JUN2018 F1 33 24 ; proc sort data = test out = test; by ID; run; proc arima data = test plots = none out = outX; by ID; identify var = X; estimate p = (1 2 3) ar = (0.3333 0.3333 0.3333) noint noest nostable method = CLS; forecast lead = 24; run; quit; proc arima data = test plots = none out = outY; by ID; identify var = Y; estimate p = (1 2 3) ar = (0.3333 0.3333 0.3333) noint noest nostable method = CLS; forecast lead = 24; run; quit;
Thanks for your reply. Do I have to write a separate code for each variable(X and Y)?
Also, when I run the query I get the following error: Forecasting was not performed because estimation was not done
Did you run my code and received the error?
As far as I can remember, you cannot specify several variables in proc arima. You need to do it separately for each variable.
yes , I didn't make any changes
I don't know why it doesn't work for you. I have it running on both SAS Studio and SAS 9.4.
@parmis wrote:
Thanks for your reply. Do I have to write a separate code for each variable(X and Y)?
Also, when I run the query I get the following error: Forecasting was not performed because estimation was not done
Go to the log, copy the log entry from the first data step using your test data set code through the end. Paste it into a code box opened with the {I} forum icon.
If you do not get the same message then there is something different in the data used.
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.