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

I am trying to introduce AR1 term into my models (lag of dependent variable). It is easy to do for the for the historic period which is lag(y). But I am wondering how to create it for the forecast period (it would actually be the lag of the prediction).  Is ther any SAS procedure or autoreg can do this??  My data looks like:

 

Date                                    Y                            lag(y)                    X1           X2

…                                          .006                      ….                        12           7

Q1 2016                              .005                      .006                      1             3             

Q2 2016                              .004                      .005                      11           7

Q3 2016                              .003                      .004                      8             7

Q4 2016                              .004                      .003                      10           6

Q1 2017                              .                             .004                      12           5

Q2 2017                              .                             .                             11           4

Q3 2017                              .                             .                             10           3

Q4 2017                              .                             .                             11           4

….

 

How do I populate lag(Y) for qtr’s Q2 2017 & beyond so that I can use it in regression??

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
alexchien
Pyrite | Level 9

Input Variables and Regression with ARMA Errors

You can use PROC ARIMA from SAS/ETS with p = 1 (AR1) along with x1 and x2 as input variables. 

proc arima data=<yourdata>; identify var=y crosscorr=(x1 x2); estimate p=1 input=(x1 x2); run;

View solution in original post

2 REPLIES 2
alexchien
Pyrite | Level 9

Input Variables and Regression with ARMA Errors

You can use PROC ARIMA from SAS/ETS with p = 1 (AR1) along with x1 and x2 as input variables. 

proc arima data=<yourdata>; identify var=y crosscorr=(x1 x2); estimate p=1 input=(x1 x2); run;
mkeintz
PROC Star

You want a one period lead for Y.  I like @alexchien's answer, but here is a way to get a one period lead:

 

data need;

  merge have

             have (firstobs=2 keep=y rename=(y=y_lead1));

run;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2264 views
  • 0 likes
  • 3 in conversation