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

Forecast the same date

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Forecast the same date

I have data :

date   stock

2010  582

2011  685

2012  562

2013  684

2014  721

2015  653

2016 586

.............

 

It's is not stationarity, so i tried :

proc arima data=stock;
identify var=stock(1);
estimate p=1;
forecast ;
run; 

And i get forecast in 2017, 2018 and etc.

But i need a program, which will forecast the same date .

I mean :

 

date   stock   forecasting

2010  582      ?

2011  685     ?

2012  562     ?

2013  684     ?

2014  721     ?

2015  653    ?

2016 586     ?

 

so first quesion: how to do it ?

second, how to do it with moving average ?


Accepted Solutions
Solution
‎05-09-2017 12:20 PM
SAS Employee
Posts: 27

Re: Forecast the same date

If you add the PRINTALL option in the FORECAST statement, then the one-step-ahead predicted values for your historical data will also be displayed by PROC ARIMA.  Note that the predicted value for 2010 cannot be computed since differencing is specified, but all other predicted values are displayed by PRINTALL for years 2011-2016, in addition to the multistep forecasts beyond the end of the data.  If you want to save the one-step-ahead predicted values and multistep forecasts to a data set, then you can also add the OUT= option to the FORECAST statement. 

 

Following, please find a modified version of your code which reads in the YEAR and STOCK, creates a SAS date variable from YEAR via the MDY function, fits your model and forecasts 4 years into the future.  The ID= and INTERVAL= options in the FORECAST statement are used to extrapolate the values of the DATE variable for your LEAD= forecast horizon.

 

 

data stock;
  input year stock;
  date=mdy(1,1,year);  /* create SAS date variable from YEAR */
  format date year4.;
  datalines;
2010  582
2011  685
2012  562
2013  684
2014  721
2015  653
2016  586
;

proc arima data=stock;
  identify var=stock(1);
  estimate p=1;
  forecast printall lead=4 id=date interval=year out=stock_fcst;
run;
quit;

proc print data=stock_fcst;
run;

 

I hope this helps!

View solution in original post


All Replies
Super User
Posts: 10,044

Re: Forecast the same date

Then you should not use PROC ARIMA or other forcast PROC,
Should use some predicted model like :
PROC REG
PROC ADAPTIVE
PROC LOESS
............


Solution
‎05-09-2017 12:20 PM
SAS Employee
Posts: 27

Re: Forecast the same date

If you add the PRINTALL option in the FORECAST statement, then the one-step-ahead predicted values for your historical data will also be displayed by PROC ARIMA.  Note that the predicted value for 2010 cannot be computed since differencing is specified, but all other predicted values are displayed by PRINTALL for years 2011-2016, in addition to the multistep forecasts beyond the end of the data.  If you want to save the one-step-ahead predicted values and multistep forecasts to a data set, then you can also add the OUT= option to the FORECAST statement. 

 

Following, please find a modified version of your code which reads in the YEAR and STOCK, creates a SAS date variable from YEAR via the MDY function, fits your model and forecasts 4 years into the future.  The ID= and INTERVAL= options in the FORECAST statement are used to extrapolate the values of the DATE variable for your LEAD= forecast horizon.

 

 

data stock;
  input year stock;
  date=mdy(1,1,year);  /* create SAS date variable from YEAR */
  format date year4.;
  datalines;
2010  582
2011  685
2012  562
2013  684
2014  721
2015  653
2016  586
;

proc arima data=stock;
  identify var=stock(1);
  estimate p=1;
  forecast printall lead=4 id=date interval=year out=stock_fcst;
run;
quit;

proc print data=stock_fcst;
run;

 

I hope this helps!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 127 views
  • 1 like
  • 3 in conversation