In Linux, we created a shell that transfers server1 to server2. Is there a way to run .sh on SAS?
Use the macro variables to generate the command you pass to the shell the same way you would use the macro variables to generate any other SAS command you want to run.
So if you want run the unix command
test.sh x y
And you have two macro variables named, for example, arg1 and arg2, like so:
%let arg1=x;
%let arg2=y;
Then you can generate that command like so:
test.sh &arg1. &arg2.
Personally I prefer to use a pipe to run the operating system commands, since then the program and read back any messages the command might reply with.
data _null_;
infile "test.sh &arg1. &arg2." pipe;
input;
put _infile_;
run;
Yes, You can execute the shell script in SAS Session using XCMD option,
It might be disabled in your Workspace Server due to security concerns, so you might have to enable it,
You can refer this link for more details about this command:
https://documentation.sas.com/?docsetId=hostunx&docsetTarget=n02699r064oqccn19vblte8xzr8m.htm&docset...
Thank you for the previous answer. One more question,
Is there a way to macro x y values in SAS when running a shell on Linux, for example sh test.sh x y?
Use the macro variables to generate the command you pass to the shell the same way you would use the macro variables to generate any other SAS command you want to run.
So if you want run the unix command
test.sh x y
And you have two macro variables named, for example, arg1 and arg2, like so:
%let arg1=x;
%let arg2=y;
Then you can generate that command like so:
test.sh &arg1. &arg2.
Personally I prefer to use a pipe to run the operating system commands, since then the program and read back any messages the command might reply with.
data _null_;
infile "test.sh &arg1. &arg2." pipe;
input;
put _infile_;
run;
Thank you very much! It was what I wanted!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.