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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 816 views
  • 0 likes
  • 2 in conversation