How do you add a number to a macro variable?
Answers were Sorted based on User's Feedback
Answer / saurabh gupta
To add a number in macro use %EVAL macro
Example
%Let a= 2;
%Let b= 3;
%Let c= &a + &b ;
then it will give you value
c=2 + 3
but If you will use %eval it will give you sum
%Let c= %eval(&a + &b)
Now this will give you the correct answer
c=5
Is This Answer Correct ? | 15 Yes | 0 No |
Answer / nani
%macro add(a,b);
%if (%datatyp(&a)=NUMERIC and %datatyp(&b)=NUMERIC) %then %
do;
%put The result is %sysevalf(&a+&b).;
%end;
%else %do;
%put Error: Addition requires numbers.;
%end;
%mend add;
You can invoke the ADD macro as:
%add(5.1E2,225)
Is This Answer Correct ? | 1 Yes | 1 No |
what is pdv? how it is related to input buffer in sas?
what do the pad and dim functions do? : Sas programming
Enlist the functions performed by sas.
What are the statements that are executed only?
Name types of category in which SAS Informats are placed?
what is hash files in sas and why we are using this one in sas?
How does the internal authentication work in sas? : sas-grid-administration
What is shift table? have you ever created shift that?
2 Answers Accenture, Clinical Research, Quintiles,
Can anyone help to find a statement to get all the predefined formats?
3 Answers Verinon Technology Solutions,
Name and describe three SAS functions that you have used, if any?
If reading an external file to produce an external file, what is the shortcut to write that record without coding every single variable on the record?
do you prefer proc report or proc tabulate? Why? : Sas programming