hi All,
Hope you are all doing well. I need small help in creating the unix variable from the sas macro variable in unix shell script.
i have go through all the available articles and links available but i am not able to succeed with this.
Below is the code am using
this is my sas code named test.sas
options symbolgen mprint;
%let toto =123;
X 'export Lvalue=&toto';
%put &=toto;
above sas code is calling in the below unix shell script named test.sh
sas -sysin /{giving the path where the test.sas file is present}/test.sas -NOPRINT -nosyntaxcheck -noerrabend
echo $Lvalue
this is the result am getting while calling it.
sh -x test.sh
+ sas -sysin /{giving the path where the test.sas file is present}/test.sas -NOPRINT -nosyntaxcheck -noerrabend
/bin/bash: toto: command not found
+ echo
my expectation was Lvalue has to resolve to 123 but am achieving with the above code.
could you please help on this. Thanks in advance for your help on this.
SAS Macro variables do not resolve inside single quotes.
X 'export Lvalue=&toto';
uses single quotes.
Try
X "export Lvalue=&toto";
Thanks for your response. I have tried that to but still not working.
The environment variable you are setting is probably only going to live for as long as the shell that is running SAS lives. So trying to find its value after SAS has finished is not likely to work.
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!
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.