Hello,
I am using the following code into a ksh file. I am able to get the first parameter but not the second.
Does someone know how to do it (see my sas code below).
#!/bin/ksh
orderdate=$1
env=$2
echo "This is environment variable read / imported in test2.ksh" $env
echo "This is orderdate variable read / imported in test2.ksh" $orderdate
nohup sas -sysparm $orderdate $env /folder_1881/test3.sas &
/*SAS program: test.sas*/ %put =========> &SYSPARM; %let orderdate = %scan(&sysparm,1); %let env = %scan(&sysparm,2); %put &=orderdate; %put &=env;
Try some quotes. You might also try SYSGET(orderdate); but I'm not sure if the shell variables are available when SAS runs.
nohup sas -sysparm "$orderdate $env" /folder_1881/test3.sas &
Try some quotes. You might also try SYSGET(orderdate); but I'm not sure if the shell variables are available when SAS runs.
nohup sas -sysparm "$orderdate $env" /folder_1881/test3.sas &
Read about how to handle multiple parameters in shell scripts.
https://unix.stackexchange.com/questions/41571/what-is-the-difference-between-and
You are not limited to using -sysparm command line option as the method to pass in values. You can also use the -set command line option to define any number of environment variables which you can retrieve with the SYSGET() or %SYSGET() functions.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostunx/n106qouqj0hfk5n1wgqpw8iovxy2.htm
Example: Say your Unix shell script called SAS in this way.
# myfile.ksh
sas -set alloptions "$*" -set option1 "$1" -set option2 "$2" myfile.sas
Then the SAS program could retrieve those three values like this:
* myfile.sas ;
%let alloptions=%sysget(alloption);
%let option1=%sysget(option1);
%let option2=%sysget(option2);
So if you called the Unix script like this:
./myfile.ksh A B C D
The macro variables will be:
ALLOPTIONS=A B C D
OPTION1=A
OPTION2=B
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.