How do you add a number to a macro variable?

Answers were Sorted based on User's Feedback



How do you add a number to a macro variable?..

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

How do you add a number to a macro variable?..

Answer / kavitha

USING %EVAL FUNCTION
%let i=%eval(&i+1);

Is This Answer Correct ?    3 Yes 1 No

How do you add a number to a macro variable?..

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

Post New Answer

More SAS Interview Questions

I am looking to buy a sas advance book. So any one can guide me that which one i should buy.

0 Answers  


In sas, what are the areas that you are most interested in? : sas-grid-administration

0 Answers  


Best trainer in hyderabad for sas banking.if any one have details pls provide contact details.

1 Answers  


What are the prime responsibilities of data integration administrator? : Sas-di

0 Answers  


Name statements that function at both compile and execution time?

1 Answers  


How do you convert basic cube to transaction cube and transaction cube to basic cube?

0 Answers  


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

0 Answers  


What is program data vector (pdv) and what are its functions?

0 Answers  


Explain append procedure?

0 Answers  


What is the function of Stop statement in a SAS Program?

0 Answers  


how to debug and test the sas program? : Sas-administrator

0 Answers  


If you could design your ideal job, what would it look like?

0 Answers   Oracle,


Categories