Hack-R
Hack-R

Reputation: 23211

Scheduled .bat file running SAS script fails to assign library but works when manually run?

I have a scheduled task which is supposed to run a SAS script daily. It's unsuccessful, however, and leads to a result of 0x2.

The .bat file is simply:

"E:\Program Files\SAS\SASFoundation\9.2\Sas.exe" -sysin "C:\Documents and Settings\username\Desktop\myfolder\myscript.sas"

I have logged the output and it indicates that the problem is that a library (and only 1 library of many) is not successfully being assigned:

2          libname COOLDB ORACLE user=Laureate pw=mypass path=COOLDB schema=ODSMGR;
NOTE: Libref COOLDB was successfully assigned as follows: 
      Engine:        ORACLE 
      Physical Name: COOLDB
3          %let prj = T:\DNA\New Orleans\username\SAS Export Folder;
4          libname dt "&prj.";
NOTE: Library DT does not exist.

where the first line is included just to demonstrate that it works up until that point.

This is strange to me because I know with 100% certainty that the folder/library being refrenced exists and has proper permissions.

When I run the same script manually there's no problem:

3    %let prj = T:\DNA\New Orleans\username\SAS Export Folder;
4    libname dt "&prj.";
NOTE: Libref DT was successfully assigned as follows:
      Engine:        V9
      Physical Name: T:\DNA\New Orleans\username\SAS Export Folder

Upvotes: 0

Views: 684

Answers (1)

Bendy
Bendy

Reputation: 3576

Depending on the server, some systems don't like the whitespace (as you have in SAS Export Folder) so you need to make sure the path in the libname statement is wrapped in quotes in these cases.

As Joe pointed out, don't double up on the quotes, so pass the path either as:

%let prj=%str(T:\DNA\New Orleans\username\SAS Export Folder);
libname dt "&prj.";

-or-

%let prj=%str("T:\DNA\New Orleans\username\SAS Export Folder");
libname dt &prj;

Upvotes: 4

Related Questions