I think that the following meets your conditions:
proc sql;
create table want as
select a.firm_ID, a.rdq, b.news
from TableA a
left join TableB b
on a.firm_ID eq b.firm_ID
where b.news le a.rdq
group by b.firm_ID,b.news
having a.rdq-b.news eq min(a.rdq-b.news)
order by a.firm_ID,b.news
;
quit;
Art, CEO, AnalystFinder.com
... View more