Hello,
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 .
Please help
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
options xwait;
somewhere prior to the X statement(s).
If not
options noxwait;
Note many sysadmins turn off the ability to issue X statements when configuring SAS.
Hi,
I am trying to execute a shell file from a SAS MACRO
I use below code:
filename runoc pipe "/test/space.try.sh";
I get message saying there is no logical file name assign to runoc.
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.
Could you please tell me why we use
2>&1?
@Babloo wrote:
Could you please tell me why we use
2>&1?
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.