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
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.
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.