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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.