07-13-2017 05:15 PM
I am trying to run a .sh file from sas. I tried the following
data _null_; call system ('cd /users/smith/report.sh'); run;
But it is not executing my script .
07-13-2017 05:21 PM
x '/users/smith/report.sh' ;
You also need to consider whether you want your SAS program to wait for the X statements complete or not. If yes, then issue
somewhere prior to the X statement(s).
Note many sysadmins turn off the ability to issue X statements when configuring SAS.
07-14-2017 03:25 AM
As @mkeintz already noted, cd won't run anything, it just (in UNIX) sets the current working directory of the shell (or, when submitted with x or call system(), the cwd of the SAS session).
The best method for executing external programs is with a filename pipe:
filename oscmd pipe "/users/smith/report.sh 2>&1"; data _null_; infile oscmd; input; put _infile_; run; filename oscmd clear;
This will catch all output (including error messages from stderr, that's done with the 2>&1 redirection) from the external program in the SAS log.
07-14-2017 04:16 AM
Could you please tell me why we use
You should start to read all of a post before answering/questioning:
Quote from my post:
(including error messages from stderr, that's done with the 2>&1 redirection)
A google search for "2>&1" will give you extensive information for why it is done.