BookmarkSubscribeRSS Feed
Ndclary
Calcite | Level 5
I have a macro that recursivly runs some functions. I noticed that the macro variables are actually the functions themselves, instead of the values. Is there a way to force them to become values?

For instance:

%let x=1
%let Piece1=(&x+1);
%let Piece2=(&x+2);

%let equation=(&Piece1/&Piece2);

Now what I want is for equation to equal .666 ... what I get is (1+1)/(1+2)

How can I force the variable to be the value instead of the equation?

Thanks!

Noble
2 REPLIES 2
JackHamilton
Lapis Lazuli | Level 10
You might take a look at the %SYSEVALF macro function, which evaluates an expression and returns a floating point result.

support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a000206831.htm
deleted_user
Not applicable
Hi,

Also, if you use call symput instead of %let, then you can pass an expression or variable instead of a literal string. For example, instead of:

%let equation=(&Piece1/&Piece2);

you would use:

call symput('equation',&piece1/&piece2);

Please note that call symput only works within a data step, so you could do something like:

data _null_;
call symput('equation',&piece1/&piece2);
run;

Thanks,
Mark

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 2 replies
  • 673 views
  • 0 likes
  • 3 in conversation