BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasgiaz
Quartz | Level 8

Hello again. I would like to do forecast with regression model. 

I use this source code but the result won't come out and I don't know what could be wrong.

 

proc reg data = armaxvlp;
model Bill = Time DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/noint;
output out = Res R = Bill_Res;
run;
forecast out = ramalan lead = 12;
run;
proc print data = ramalan (obs = 48);
run;

 

Thankyou.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If you are fitting a regression on a monthly data set, from 2016 to 2018, and now you want forecasts for 2019, you can get predicted values for 2019 but you need to have all the values of the x-variables in the regression present, plus Waktu must be months in 2019.

 

In other words, all the variables in

 

model Bill = Waktu DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/noint;

except for the y-variable BILL must be present (not missing). Then you can get predicted values from the output statement.

 

output out = Res R = Bill_Res p=bill_pred;
--
Paige Miller

View solution in original post

19 REPLIES 19
PaigeMiller
Diamond | Level 26

@sasgiaz wrote:

Hello again. I would like to do forecast with regression model. 

I use this source code but the result won't come out and I don't know what could be wrong.


We need a lot more information than just saying that the results don't come out.

 

Please be specific and detailed.


Show us the SAS LOG (Click on the {i} icon and paste the log into that window DO NOT SKIP THIS STEP)

 

Show us the results where you don't see what you want to see.

--
Paige Miller
sasgiaz
Quartz | Level 8

It says like this

 

NOTE: The previous statement has been deleted.
132 *Peramalan;
133 forecast out = ramalan lead = 12;
--------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
134 run;

WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.RES may be incomplete. When this step was stopped there were 36
observations and 14 variables.
WARNING: Data set WORK.RES was not replaced because this step was stopped.
NOTE: PROCEDURE REG used (Total process time):
real time 17.98 seconds
cpu time 2.07 seconds

 

PaigeMiller
Diamond | Level 26

Click on the {i} icon and paste the log into that window DO NOT SKIP THIS STEP

 

Don't just show us the errors, we need to see the entire LOG for this PROC.

--
Paige Miller
sasgiaz
Quartz | Level 8

Sure, is this explain enough?

 

161 proc reg data = armaxvlp;
162 model Bill = Waktu DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/influence;
163 output out = Res R = Bill_Res;
164 run;

165 *Pemodelan ARMAX Variasi Liburan dan Perdagangan Trend Deterministik Tanpa Variabel
165! Konstan;

NOTE: The data set WORK.RES has 36 observations and 14 variables.
NOTE: PROCEDURE REG used (Total process time):
real time 2.15 seconds
cpu time 0.53 seconds


166 proc reg data = armaxvlp;
167 model Bill = Waktu DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/noint;
168 output out = Res R = Bill_Res;
169 run;

170 *Peramalan;
171 forecast out = ramalan lead = 12;
--------
180
NOTE: The previous statement has been deleted.
ERROR 180-322: Statement is not valid or it is used out of proper order.
172 run;

PaigeMiller
Diamond | Level 26

We're trying to help you, but you have to help us. Click on the {i} icon and paste the log into that window.

--
Paige Miller
sasgiaz
Quartz | Level 8

I can not find the {i} icon

PaigeMiller
Diamond | Level 26

It is in the icon bar immediately above where you type your messages, sixth from the left.

--
Paige Miller
sasgiaz
Quartz | Level 8
210  proc reg data = armaxvlp;
211  model Bill = Waktu DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/noint;
212  output out = Res R = Bill_Res;
213  run;

214
215  *Peramalan;
216  forecast out = ramalan lead = 12;
     --------
     180
NOTE: The previous statement has been deleted.
ERROR 180-322: Statement is not valid or it is used out of proper order.
217  run;

WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.RES may be incomplete.  When this step was stopped there were 36
         observations and 14 variables.
WARNING: Data set WORK.RES was not replaced because this step was stopped.
NOTE: PROCEDURE REG used (Total process time):
      real time           2.00 seconds
      cpu time            0.53 seconds



218  proc print data = ramalan (obs = 48);
ERROR: File WORK.RAMALAN.DATA does not exist.
219  run;
PaigeMiller
Diamond | Level 26

Thanks.

 

There is no FORECAST statement in PROC REG. So, the FORECAST statement doesn't execute and produce an output data set. When you put a RUN; statement in PROC REG, it executes the command, but does not end PROC REG. You need a QUIT; statement to end PROC REG, it should go immediately after the RUN; statement.

 

If you want to do a time series forecast, there are other tools that can do this (one is PROC ARIMA), or you can have PROC REG do a very crude forecast, for example if you had data from 1980 to 2018, and the year is a term in the model, you could have a crude forecast from PROC REG for 2019, but I don't see how that would fit here, as you don't seem to have a time variable in your model.

--
Paige Miller
sasgiaz
Quartz | Level 8

I have the time variable which I named it as "Waktu". If that so, I still can have the forecast from the proc reg?

Because, actually I use the regression analysis on my time series data to analyze holiday and trading day variation.

So I got the regression model as its best fit and want to do the forecast for at least a year.

sasgiaz
Quartz | Level 8
For the record, the data I have is from 2016 to 2018, monthly.
PaigeMiller
Diamond | Level 26

If you are fitting a regression on a monthly data set, from 2016 to 2018, and now you want forecasts for 2019, you can get predicted values for 2019 but you need to have all the values of the x-variables in the regression present, plus Waktu must be months in 2019.

 

In other words, all the variables in

 

model Bill = Waktu DL1 DL2 DL3 D1 D2 D3 D4 D5 D6 Mt/noint;

except for the y-variable BILL must be present (not missing). Then you can get predicted values from the output statement.

 

output out = Res R = Bill_Res p=bill_pred;
--
Paige Miller
sasgiaz
Quartz | Level 8

But if I have all the value of x variables untill 2019, I will have different value of parameters for the best fit models, right? how about that...

PaigeMiller
Diamond | Level 26

@sasgiaz wrote:

But if I have all the value of x variables untill 2019, I will have different value of parameters for the best fit models, right? how about that...


I don't know what you mean. Explain further.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 19 replies
  • 3214 views
  • 0 likes
  • 2 in conversation