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 sas data set?
What is the order of evaluation of the comparison operators: + - * /** ()?
please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??
Differentiate input and infile.
Can Some one Explain How the Datasets from SAS can be loaded in to the MVS OS?
What will calendar procedure do?
Does anybody has lastest SAS certification dumps,if anybody has please mail me at akshara_SAS@ymail.com Thanks Akshara
How to create an external dataset with sas code?
In proc transpose and data step with arrays which one you pick?
0 Answers Accenture, Quintiles,
Can you execute macro within another macro? : sas-macro
How do you control the number of observations and/or variables read or written? Approximately what date is represented by the SAS date value of 730?
what are the new features included in the new version of SAS i.e., SAS9.1.3?
5 Answers College School Exams Tests, Wockhardt,