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;
 

  

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1211 views
  • 0 likes
  • 3 in conversation