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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

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
  • 1973 views
  • 0 likes
  • 2 in conversation