How many ids are in the WORK table? If the list is small enough you might be able to use a macro variable to build your WHERE condition.
Do you want all of the values from the DB2 table for the ID's in your WORK table?
proc sql noprint;
select distinct ID into :list seprated by ',' from work.table2;
CONNECT TO db2(login stuff);
CREATE TABLE table3 as
SELECT * from connection to db2
(SELECT B.*
FROM schema.db2table b
where b.id in (&list)
)
;
quit;
If the ID variable is character instead of numeric then change select distinct id into to select distinct quote(trim(id),"'") into .
If you just want the list of matching ids then change SELECT B.* to select distinct b.id .
... View more