BookmarkSubscribeRSS Feed
laika_matias
Obsidian | Level 7

VBScript runs successfully when executed from SAS Base, but doesn't work in batch mode (I cannot see any errors).


DATA _NULL_;
RC=SLEEP(5);
RUN;

option noxwait;
option noxsync ;
data _NULL_;
rc1=system('path\copy_cal.vbs');
put rc1;
run;

DATA _NULL_;
RC=SLEEP(5);
RUN;

 

 

9 REPLIES 9
SASKiwi
PROC Star

Check the XCMD SAS system option in batch mode to confirm if SAS will let you execute commands in the OS or not:

proc options option = xcmd;
run;
laika_matias
Obsidian | Level 7

Thank you for your response! 🙂 I have checked the XCMD SAS system option in batch mode, and it shows that it is enabled. There are no errors in the log, and everything appears to be working fine. However, the VBScript code still does not seem to execute.

 

XCMD              Enables the X command in SAS.

NOTE: PROCEDURE OPTIONS used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

65        

66         option  noxwait nosyntaxcheck;

67         option  noxsync ;

68        

69         data _NULL_;

70         rc1=system('G:\path\script.vbs');

71         put rc1;

72         run;

 

0

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

 

73        

74         proc options option=xcmd;

75         run;

 

    SAS (r) Program  9.4  TS1M3

 

XCMD              Enables the X command in SAS.

NOTE: PROCEDURE OPTIONS used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

Patrick
Opal | Level 21

Just as a thought: The vbs script executes as a child process of your parent SAS session. When running in batch and the parent SAS session terminates the child session will get killed if not finished already.

To test the theory: Use options XWAIT and XSYNC and see if this changes things.

laika_matias
Obsidian | Level 7

Thank you! but I already have those options added 😕

Patrick
Opal | Level 21

@laika_matias wrote:

Thank you! but I already have those options added 😕


So the SAS log you shared with us is not what you executed? As in the log it's NOxwait and NOxsync

Patrick_0-1713530874530.png

 

laika_matias
Obsidian | Level 7

I've just tried to execute the code according to the options you provided, but still nothing 😕

laika_matias
Obsidian | Level 7

It seems that the 'xwait' option is causing the SAS application to hang while executing its task.

Quentin
Super User

What OS are you running on?

 

Maybe just to separate the SAS stuff from the VBS script try just running a single command, like:

 

options noxwait xsync ;
data _NULL_;
rc1=system('/*run some command here to make a directory or a file*/');
put rc1;
run;

You also might try using SYSTASK, something like:

systask command "/*your command here*/" status=mystatus wait shell;  
%put &=mystatus &=sysrc; *both should be 0 if success;
The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
data_null__
Jade | Level 19

What exactly does "when executed from SAS Base" mean?

 


@laika_matias wrote:

VBScript runs successfully when executed from SAS Base, but doesn't work in batch mode (I cannot see any errors).


DATA _NULL_;
RC=SLEEP(5);
RUN;

option noxwait;
option noxsync ;
data _NULL_;
rc1=system('path\copy_cal.vbs');
put rc1;
run;

DATA _NULL_;
RC=SLEEP(5);
RUN;

 

 


 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 9 replies
  • 1584 views
  • 6 likes
  • 5 in conversation