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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: