Direct access
data a;
input Id $ Date : mmddyy10.;
format date mmddyy10.;
cards;
A1 01/02/19
D1 01/15/19
A1 01/24/19
D1 01/20/19
;
data b;
input Id $ Date : mmddyy10.;
format date mmddyy10.;
cards;
A1 01/01/19
D1 01/13/19
A1 01/23/19
D1 01/18/19
;
data want;
set a ;
if _n_=1 then do;
if 0 then set b(rename=(date=last_serv_date));
declare hash H (dataset:'b(rename=(date=last_serv_date))',multidata:'y',ordered:'d') ;
h.definekey ("id","last_serv_date") ;
h.definedata ("last_serv_date") ;
h.definedone () ;
declare hiter hh('h');
end;
rc=h.add(key:id,key:date,data:date);
rc = hh.setcur(key:id,key:date) ;
rc=hh.next();
drop rc;
run;
... View more