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 |
I am looking to buy a sas advance book. So any one can guide me that which one i should buy.
In sas, what are the areas that you are most interested in? : sas-grid-administration
Best trainer in hyderabad for sas banking.if any one have details pls provide contact details.
What are the prime responsibilities of data integration administrator? : Sas-di
Name statements that function at both compile and execution time?
How do you convert basic cube to transaction cube and transaction cube to basic cube?
I am preparing SAS Certified Advanced Programmer for SAS 9 in 2014. If anybody has the latest dumps for this exam, please mail me at dhiman.mukherjee@gmail.com
What is program data vector (pdv) and what are its functions?
Explain append procedure?
What is the function of Stop statement in a SAS Program?
how to debug and test the sas program? : Sas-administrator
If you could design your ideal job, what would it look like?