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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.