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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.