My data has ID, date, Value. For each Id, at a given date, I want to find the Max value up to that date.
My code below works but I wonder if there is any shorter/faster way, such as using proc expand.
input id date value;
1 1 2
1 2 15
1 3 6
1 4 17
1 5 8
1 6 9
2 1 60
2 2 50
2 3 600
proc sort data=have; by id descending date; run;
set have nobs=nobs;
drop i j _: exit;
do j=i to nobs until (exit=1);
set have (keep=id date value rename=(id=_id date = _date value=_value)) point=j;
if id^=_id then do;exit=1;leave; end;
if max_value<_value then max_value=_value;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.