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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.