- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-13-2019 11:34 AM
(755 views)
Folks,
I have a dataset of transactions for people and I need to identify which ones are the latest. I have a timestamp variable which we can call time_stamp and I have an ID variable which we call ID.
Timestamp is numeric with larger values meaning its more recent to the system.
So I did to run some code that outputs the latest value for an individual when the timestamp is the largest for that id.
Could anyone supply and ideas please?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sort ascending or descending and use FIRST or LAST respectively to get the first or last record for each ID.
proc sort data=have;
by ID time_stamp;
run;
data want;
set have;
by id time_stamp;
if last.id;
run;
proc sort data=have;
by ID time_stamp;
run;
data want;
set have;
by id time_stamp;
if last.id;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or use the MAX() function in SQL or PROC MEANS.