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 do you know about sas and what we do? : sas-grid-administration
Explain the special input delimiters used in sas programming.
In sas admin differentiate between roles and capabilities? : sas-grid-administration
In PROC PRINT, can you print only variables that begin with the letter “A”?
what is the use of proc sql? : Sas programming
How does proc sql work?
for whom is sas data integration studio designed? : Sas-di
6) Explain about below automatic variables a) _N_ b) _ERROR_ c) _CHAR_ d) _NUMERIC_ e) _ALL_ f) FIRST.BY VARIABLE g) LAST.BY VARIABLE h) _NAME_ i) _TYPE_ j) _FREQ_ k) _STAT_ l) _BREAK
Which function is used to count the number of intervals between two sas dates?
what is the difference between the SAS v8 and SAS v9?
Hi All.I am looking for Good Institute who could Provide the online SAS BI+DI Training along with software.Primarily in Delhi/NCR or in Hyderabad Please help with name and contact number of concerned person!! Thanks in Advance! :)
what is picture format? give any one example?