BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I need help in SAS Enterprise Guide. I have a table containing current and historical data. The data is in the same column as such:

date name value
7/5 John 5
current John 10

I need SAS to return the difference. If there is no difference, then it won't return a value.

Any help would be greatly appreciated.


Thanks,
2 REPLIES 2
datalligence
Fluorite | Level 6
Not very sure of what you exactly want but i think you can try using the first.variable_name, last.variable_name, and the lag function.

data yourdata;
by name date;
if first.date <> last.date then;
diff_date=date-lag(date);
diff_value=date-lag(value);
....
....

Thanks,
Romakanta
deleted_user
Not applicable
Thanks Romakanta.

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 lock in 2025 pricing—just $495!

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