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/
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.