Hello SAS Communities,
What is the value of the following macro variable NewVbl?
%LET NewVbl = 10+20;
Thank you!
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
@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...
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.
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;
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!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.