Desktop productivity for business analysts and programmers

Camparing two data fields

Reply
N/A
Posts: 0

Camparing two data fields

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,
Contributor
Posts: 35

Re: Camparing two data fields

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
N/A
Posts: 0

Re: Camparing two data fields

Thanks Romakanta.
Ask a Question
Discussion stats
  • 2 replies
  • 121 views
  • 0 likes
  • 2 in conversation