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 2025: Call for Content

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!

Submit your idea!

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
  • 606 views
  • 0 likes
  • 3 in conversation