Hi all,
The code below is producing an error because the Sheet does not exist, which is true. Can fileexist be used to check for the existence of an excel worksheet?
(and then conditionally continue to the next datastep only if the sheet exists)
proc import out=sae1a
datafile= "&sas_dir\sas_production\output\reconciliation\sae reconciliation_master.xlsx"
dbms=excelcs replace;
sheet='SAE-Discrepant$A7:AD999';
ERROR: File _IMEX_.'SAE-Discrepant$A7:AD999'n.DATA does not exist.
data sae1b sae1c;
length subject $150 rec1 $5;
set sae1a (rename=OK_AS_IS__ENTER_YES_IF_UNRECONCI=ok_as_is);
xxxx
xxxx
ERROR: File WORK.SAE1A.DATA does not exist.
Thanks for your time! NJGIRL
You can define a libname (XLSX) to the Excel workbook, and then check dictionary.tables for the presence of the sheet (dataset).
I suggest you try PROC CONTENTS after running your LIBNAME to report on the sheets SAS sees in your workbook:
libname MyExcel XLSX "&sas_dir\sas_production\output\reconciliation\sae reconciliation_master.xlsx";
proc contents library = MyExcel;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.