BookmarkSubscribeRSS Feed
NJGIRL
Obsidian | Level 7

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

4 REPLIES 4
NJGIRL
Obsidian | Level 7
Thanks!

Let me give that a whirl.

NJGIRL
Obsidian | Level 7
Unfortunately, I can't get this to work. I established the Libname statement with the xlsx engine, then I check for the existence, but unsure of the code to proceed to next step and conditionally execute if the spreadsheet exists, if not, I need to bypass the datastep. any additional feedback? thanks!
SASKiwi
PROC Star

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;
 

  

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

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