proc sql;
create table ccc as
select b.stock, a.stock as stock_, date, r, edate from
aaa as a full join bbb as b on a.stock=b.stock and b.date=a.edate
;
quit;
data ccc;
set ccc;
if stock=. then stock=stock_;
drop stock_;
run;
but not sorted as in your final dataset...waiting for better solution...