BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BenConner
Pyrite | Level 9


Hi,

I'm looking for ideas on how to handle error conditions from a missing or renamed tab when using Proc Import in a batch mode.  I've been asked to read in a lot of older excel files, each of which has multiple tabs.  I can easily detect if the file itself is present with the fileexist() function.  Not so much with a missing or mis-named tab within the spreadsheet.

Each proc import is followed by a data step to transform it, then a proc append.  If proc import doesn't find the tab, it won't create the output file as it doesn't know what to put in it.  The data step then chokes on a missing input dataset.

Thanks!

--Ben

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

You could try a LIBNAME statement with the EXCEL option. When you assign your LIBNAME to a workbook, all of the tabs will be listed in a PROC CONTENTS of the library. You could also use the EXIST function to test if a tab is present or not.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

You could try a LIBNAME statement with the EXCEL option. When you assign your LIBNAME to a workbook, all of the tabs will be listed in a PROC CONTENTS of the library. You could also use the EXIST function to test if a tab is present or not.

BenConner
Pyrite | Level 9

Of course.  Then I can get direct access to what they -really- used for tab names and conditionally execute the transform/append steps.  And no nastygrams in the log files! Smiley Happy

Much appreciated!

--Ben

BenConner
Pyrite | Level 9

As a followup, is there a way to disable SAS looking for field names on the first line of the spreadsheet in the "Libname Excel ..." approach?  It picked up a title and none of the columns have reasonable data for fieldnames.

Thanks!

--Ben

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1459 views
  • 0 likes
  • 2 in conversation