It seems you should reduce the volume as much as possible in Oracle:
Sum the amounts and count the records, using group by ID, USER. This is the pass-through query.
This query is joined to the SAS table.
The syntax could be something like:
libname ORADB oracle user=&NAME password=&pASS path=ExaODIN preserve_comments;
proc sql;
connect using ORADB;
create table SAME as
select A.*, SUM, COUNT
from A
left join connection to ORADB
(select ID, DATE, USER, sum(AMT) as SUM, count(*) as COUNT
from B
group by A.ID, B.USER_ID)
on A.ID = B.ID
and A.DATE = B.DATE
and A.USER = B.USER
;
quit;
... View more