lag

Accepted Solution Solved
Reply
Valued Guide
Posts: 858
Accepted Solution

lag

I've attached a file with some code.  I would like to get the equivalent to =B3+C3-D2-G2 in excel but my code is not performing the way that I want it too.  I'm not sure if lag what I should be using here.  Any help is appreciated.

Thank You,

Mark

Attachment

Accepted Solutions
Solution
‎12-05-2014 10:42 AM
Super User
Posts: 11,134

Re: lag

LAG has some pretty complex relationships with conditional execution.

You would be better to create a new variable such as Lpayment= lag(payment); BEFORE the IF not line of code and use Lpayment instead of lag(payment) within the calculation.

View solution in original post


All Replies
Solution
‎12-05-2014 10:42 AM
Super User
Posts: 11,134

Re: lag

LAG has some pretty complex relationships with conditional execution.

You would be better to create a new variable such as Lpayment= lag(payment); BEFORE the IF not line of code and use Lpayment instead of lag(payment) within the calculation.

Valued Guide
Posts: 3,208

Re: lag

do not confuse the queue function with the lag function.

There is no complexity when you understand that what SAS has implemented is a QUEUE http://en.wikipedia.org/wiki/Queue_(abstract_data_type)  and has named that wrong as LAG http://msdn.microsoft.com/en-us/library/hh231256.aspx

Wrong naming can cause confusions, correct that and it will become easy. 

---->-- ja karman --<-----
Valued Guide
Posts: 858

Re: lag

Before the IF NOT line payment has no value, I'm putting it after the if not and after the payment = statement.  That seems to get me the output I am looking for.

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 219 views
  • 0 likes
  • 3 in conversation