BookmarkSubscribeRSS Feed
mike111111
Calcite | Level 5

I am new to SAS and have a question for help. Here is the simplified question.

 

I am looking X effect on Lagged Y, let's say Lag1_Y=k*X +c. There are total 6 observations of "X" and "Y".

 

ObsXYLag1_Y
1x1y1 
2x2y2y2
3x3y3y3
4x4y4y4
5x5y5y5
6x6y6y6

 

I lagged variable "Y" and get 5 observations for "Lag1_Y".   Now the effective observation pairs are 5:

 

1    x1 y2

2   x2 y3

3   x3 y4

4   x4 y5

5   x5 y6

 

How should I use the lagged variable in model? Do the original dates need to be modified as the dates shown in lower portion before regression analysis? I appreciate your help in advance 

 

3 REPLIES 3
ballardw
Super User

What kind of model? Some of the time-series procedures are set up to handle such internally. I suggest providing much more detail about what you are attempting. I mention time-series because your question included "Do the original dates need to be modified as the dates" and there is no indication as to where such dates might reside.

I also think that your "example" is incorrect. I would expect something more like:

 

Obs X Y Lag1_Y
1 x1 y1  
2 x2 y2 y1
3 x3 y3 y2
4 x4 y4 y3
5 x5 y5 y4
6 x6 y6 y5

 

Also if there are ANY other variables in your model then how they are used might have an impact on how the Lags are calculated. For example if one variable indicates a geography, product or other grouping variable (typically a CLASS variable in SAS) then you likely do not want the lagged value from a different group to be included.

 


@mike111111 wrote:

I am new to SAS and have a question for help. Here is the simplified question.

 

I am looking X effect on Lagged Y, let's say Lag1_Y=k*X +c. There are total 6 observations of "X" and "Y".

 

Obs X Y Lag1_Y
1 x1 y1  
2 x2 y2 y2
3 x3 y3 y3
4 x4 y4 y4
5 x5 y5 y5
6 x6 y6 y6

 

I lagged variable "Y" and get 5 observations for "Lag1_Y".   Now the effective observation pairs are 5:

 

1    x1 y2

2   x2 y3

3   x3 y4

4   x4 y5

5   x5 y6

 

How should I use the lagged variable in model? Do the original dates need to be modified as the dates shown in lower portion before regression analysis? I appreciate your help in advance 

 


 

mike111111
Calcite | Level 5

Thanks for the response. 

 

Yes. It is time series analysis.  New lagged variable could be used directly for time series analysis without any further operation. First observation pair will be ignored by SAS automatically?

Ksharp
Super User

Since it is related to SAS/ETS, it is better to post it at Forecast Forum:

https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/bd-p/forecasting_econometrics

 

And it seems that you are doing 1-order auto regression model. Try PROC AUTOREG:

proc autoreg data=sashelp.stocks;
model close= /dw=1 dwprob;
run;

 

 

And also Check 


PROC ARIMA 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1065 views
  • 2 likes
  • 3 in conversation