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.

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