What do you expect as result?
Assuming that the variable "id" exists in every dataset in libname example and it is always numeric, you could write this for one dataset:
proc sql;
select *
from example.first
where Id = 5;
quit;
The datasets existing in one library can be retrieved from sashelp.vtable:
proc sql noprint;
create table work.tables as
select cats(LibName, '.', MemName) as Dataset
from sashelp.vtable
where LibName = 'EXAMPLE';
quit;
The result is used to create a select-statement for each table:
data _null_;
set work.tables end=jobDone;
if _n_ = 1 then do;
call execute('proc sql;');
end;
call execute(catx(' ', 'select * from', Dataset, 'where Id = 5;'));
if jobDone then do;
call execute('quit;');
end;
run;
Code is untested!
... View more