How do you add a number to a macro variable?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you execute a macro within a macro? Describe. : sas-macro

853


I have a dataset concat having variable a b & c. How to rename a b to e & f?

788


Explain data_null_?

796


where to use sas business intelligence? : Sas-bi

770


what does the run statement do? : Sas programming

769


Explain the difference between using drop = data set option in set and data statement?

912


what is data governance? : Sas-di

786


Tell e how how dealt with..

1977


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 ...

1144


Name some categories in sas 9? : sas-grid-administration

731


How to convert a numeric variable to a character variable?

860


how do you debug and test your sas programs? : Sas programming

825


If you use a symput in a data step, when and where can you use the macro variable? : sas-macro

815


Explain the main difference between the sas procedures and functions? : Sas-administrator

757


What are pdv and it functions?

761