BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NikitaTovey
Fluorite | Level 6

Hello SAS Communities, 

 

What is the value of the following macro variable NewVbl?

%LET NewVbl = 10+20;

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
JoshB
Quartz | Level 8
It is the characters you just assigned. It is 10+20

View solution in original post

5 REPLIES 5
rhaley1821
Obsidian | Level 7

Hello!

 

The value of the macro variable is the value that you assign it and will remain the same until explicitly changed. Your macro variable newvbl will have a value of 10+20. 

 

Here is a helpful link for better understanding how macros work: https://v8doc.sas.com/sashtml/macro/z1071889.htm 

andreas_lds
Jade | Level 19

@rhaley1821 wrote:

Hello!

 

The value of the macro variable is the value that you assign it and will remain the same until explicitly changed. Your macro variable newvbl will have a value of 30. 

 

Here is a helpful link for better understanding how macros work: https://v8doc.sas.com/sashtml/macro/z1071889.htm 


No, the value is the string assigned to the variable, if you want to calculate, you have to use %eval or %sysevalf.

 

@NikitaTovey see maxim 4 in https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers...

JoshB
Quartz | Level 8
It is the characters you just assigned. It is 10+20
ballardw
Super User

Some teacher seems not not explain things very well.

 

https://communities.sas.com/t5/SAS-Programming/Creating-a-Macro-variable/m-p/704449

 

There was another essentially identical question that I can't find as well.

gamotte
Rhodochrosite | Level 12

Hello,

 

Here is an example to illustrate what @andreas_lds explained :

%let x=10+20;

data _NULL_;
y = 5 * &x. * 2; /* 5*10+20*2 */
z = 5 * %eval(&x.) *2; /* 5*30*2 */
put y=; /* 90 (50+40) not 300 (5*30*2) */ 
put z=; /* 300 */
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 5 replies
  • 1804 views
  • 3 likes
  • 6 in conversation