BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
teelov
Quartz | Level 8
THIS IS PERFECT!!!

i had no idea you can process first. twice

it turns out my mistake creating the counter in WANT actually helped.

Thank you
Ksharp
Super User
data have;
infile cards truncover;
input ID $	DATE_OF_VALUE :ddmmyy10.	VALUE	HAVE;
format DATE_OF_VALUE date9.;
cards;
109999999 05/12/2017 42376 1
109999999 05/12/2017 42376 2
109999999 13/12/2017 42521 1
109999999 13/12/2017 42521 2
109999999 19/03/2018 43395 1
109999999 19/03/2018 43395 2
109999999 19/03/2018 43395 3
109999999 19/03/2018 43395 4
109999999 04/06/2018 43953 1
109999999 04/06/2018 43953 2
109999999 17/09/2018 44899 1
109999999 17/09/2018 44899 2
;

proc sort data=have;
by id descending DATE_OF_VALUE;
run;

data want;
set have;
by id value notsorted;
temp+first.value; 
want=temp;
if not first.value then call missing(want);
drop temp;
run;

proc sort data=want;
by id DATE_OF_VALUE ;
run;

proc print;run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 2348 views
  • 5 likes
  • 5 in conversation