DATA Step, Macro, Functions and more

lag function

Reply
Regular Contributor
Posts: 241

lag function

[ Edited ]

Hello everyone,

 

Is there a lag like function can get reversed lag without merging tables?

 

currently we have lag1(var),lag2(var).......,can we do something like lag(var,-1),lag(var,-2)......? this avoid merge tables.

 

 

Thanks!

PROC Star
Posts: 7,492

Re: lag function

Posted in reply to GeorgeSAS

If by reverse lag you mean look ahead, I don't think so. But it's quite easy, see: http://www.sascommunity.org/wiki/Look-Ahead_and_Look-Back

 

Art, CEO, AnalystFinder.com

 

Regular Contributor
Posts: 241

Re: lag function

Thank you art, while this method still need to merge table.
Contributor
Posts: 23

Re: lag function

Posted in reply to GeorgeSAS

If you are able, you could sort in the reverse way and use the lag function to get the "reverse" lag.

Ask a Question
Discussion stats
  • 3 replies
  • 96 views
  • 0 likes
  • 3 in conversation