BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steelers_In_DC
Barite | Level 11

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
ballardw
Super User

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.

jakarman
Barite | Level 11

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 --<-----
Steelers_In_DC
Barite | Level 11

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.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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