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;

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