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
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.
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.
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!
Much appreciated!
--Ben
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.