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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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