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 |
how do you read binary data in sas?
What are the special input delimiters used in SAS?
What is the difference between reading data from an external file and reading data from an existing data set?
what are the three main credit bureau names
1 Answers Synchrony Financial,
Do we follow ADAM in analysis dataset development?How? Usually which version? Why is it necessary?
How would you code a macro statement to produce information on the sas log? This statement can be coded anywhere? : sas-macro
how can you create zero observation dataset? : Sas programming
What commands are used in the case of including or excluding any specific variables in the data set?
if a variable contain dates like "2015/01"---"2015/12" (yymm) ,How to add day to those dates,if them month is jan then 31 if the month is feb then 28 so on ...
How would you delete observations with duplicate keys?
If you?re not wanting any SAS output from a data step, how would you code the data statement to prevent SAS from producing a set?
Which are SAS Windows Clients & SAS Java Clients