CrudeOperator
CrudeOperator

Reputation: 111

SAS script unable to import Excel file when ran from Batch script but is able when script is ran directly from SAS UI

I have a SAS script that I initiate from a batch script. When I ran the batch script earlier, the log said that the file I tried to import ran into an error, as below:

ERROR: XLSX file does not exist -> C:......\etc\excelfile.xlsx NOTE: The SAS System stopped processing this step because of errors.

When I ran the same script manually from the SAS UI, the script ran fine without any errors. When I looked at the log on that occasion, below were the notes for same file I had issues when importing from batch:

NOTE: The import data set has 1000 observations and 100 variables. NOTE: WORK.have data set was successfully created.

NOTE: PROCEDURE IMPORT used (Total process time): real time 3.06 seconds cpu time 2.23 seconds

It might be worth mentioning that this SAS script imports other files also, and they imported fine - even when initiated from batch. Has anyone else ran into this issue before?

Batch Script:

"C:\Program Files\SASHome\x86\SASFoundation\9.3\sas.exe" -SYSIN 
"C:\...\...\..\etc\sas_script_file.sas" -PRINT 
"C:\...\...\...\....\etc\sas_script_file.lst"

Import Procedure on SAS:

proc import OUT=work.have (keep = col1 col2 col3 col4)
datafile="C:\...\...\...\etc\excelfile.xlsx"
DBMS=XLSX REPLACE;
SHEET= "Sheet1";
run;

Upvotes: 0

Views: 240

Answers (1)

AlanC
AlanC

Reputation: 584

There are 2 areas I would look at:

  • What security context is the script running under, specifically what user is executing it? It is probably a system security context and that context doesn't have access to the files.

  • Where is the script running and is the path to the place it is running not matching the relative paths defined.

Upvotes: 1

Related Questions