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;
BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: 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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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