BookmarkSubscribeRSS Feed
Emma2021
Quartz | Level 8
I have multiple excel (xls or XLSX) files. I would like to import into sas but the sheet names are “upcoming” or sometimes “upcomings” -added s or not. How can I read into without checking the exact sheet name? Such is SHEET=upcoming* would not work.
Thank you.
4 REPLIES 4
whymath
Lapis Lazuli | Level 10
If there is only one sheet in each excel file, you can using proc import without "sheet=" option.
Emma2021
Quartz | Level 8
Each excel file has multiple sheets but I wanted only start with upcoming*

Thank you.
Tom
Super User Tom
Super User

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?).

A_Kh
Lapis Lazuli | Level 10

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 804 views
  • 4 likes
  • 4 in conversation