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

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
dw_sas
SAS Employee

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

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


dw_sas
SAS Employee

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

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.

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