- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- "cd" is change directory. It will not run the script.
- Have you tried the X statement? It's a global statement (i.e. does not need to be (should not be) inside a DATA step or other PROC step. See http://www.sascommunity.org/wiki/X_statement
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.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- don't hijack a thread that's two years old. Almost nobody will see your question. Open your own thread in SAS Programming.
- in this new thread, post your whole log (from the filename statement to the ERROR message), using the {i} button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Could you please tell me why we use
2>&1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.