Define "multiple datasets". Are these datasets in different libraries, or all in one library? Do they share a common naming structure (e.g. all dataset names start with the same string)?
First select the names:
proc sql noprint;
select memname into :dsnames separated by " "
from dictionary.tables
where libname = "LIBRARY" and memname like '%NAME';
quit;
Then copy to Excel:
libname ex xlsx "/path to your Excel file";
proc copy in=library out=ex;
select &dsnames.;
run;
or do it in one step with a wildcard:
libname ex xlsx "/path to your Excel file";
proc copy in=library out=ex;
select name:;
run;
The first selection method allows you to use more complicated selection rules.
I am surprised that non of the solution already posted for this problem fits your needs.
If you have AccessTo PcFiles licensed, maybe libname + proc copy is all you need. You won't need a macro, most likely.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.