BookmarkSubscribeRSS Feed
sasismylife
Fluorite | Level 6

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. 

3 REPLIES 3
ballardw
Super User

 SAS Macro variables do not resolve inside single quotes.

 

X 'export Lvalue=&toto';

uses single quotes.

 

Try

X "export Lvalue=&toto";

 

 

sasismylife
Fluorite | Level 6

Thanks for your response. I have tried that to but still not working.

Tom
Super User Tom
Super User

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.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 711 views
  • 0 likes
  • 3 in conversation