BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I'm trying to create a lagged variable (the difference between two rows) with the query builder... with no success. In SAS, I would use the lag or dif functions, but with EG I get an error message.

Is there a function that would do this in EG? How would you define this variable?

Thanks,
D.
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
You cannot use the LAG function with PROC SQL: http://support.sas.com/techsup/unotes/SN/014/014659.html
Since the EG query builder is building SQL, that is probably the source of the error message you are getting.

But, you can open a code node and use your DATA step code with the LAG function, per these examples:
http://support.sas.com/ctx/samples/index.jsp?sid=1498&tab=code
http://support.sas.com/ctx/samples/index.jsp?sid=108&tab=code

cynthia
deleted_user
Not applicable
Thank you,

It did solve my small problem,

D.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1881 views
  • 0 likes
  • 2 in conversation