For XLSX files you can just read the actual XML file that is inside the file to find the sheet names.
For example to find the sheets in the xlsx file named book1.xlsx in the directory c:\downloads I could run this program.
data worksheets;
infile "c:\downloads\book1.xlsx" zip member='xl/workbook.xml' recfm=n dsd dlm=' ';
sheet_number+1;
input @'<sheet name=' sheet_name :$32. @@;
run;
No idea how you would do it with XLS files (why do you still have XLS files anyway?).
If you have SAS/ACCESS then Libname xlsx engine will allow to read all sheets without checking sheet names. Refer to the documentation https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.