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

what are the softwares and applications that are used most frequently used by sas bi applications developers? : Sas-bi

0 Answers  


Does SAS ?Translate? (compile) or does it ?Interpret?? Explain.

10 Answers  


what is the effect of the options statement errors=1? : Sas programming

0 Answers  


how do you want missing values handled? : Sas programming

0 Answers  


Mention the difference between ceil and floor functions in sas?

0 Answers  






How to specify variables to be processed by the freq procedure?

0 Answers  


what is prime numbers? how we can get plc write sas code?

5 Answers   Icon,


Do you need to rearrange the order of the data for the report?

0 Answers  


1.How to draw pivot tables in Excel by using SAS and in which version we can use VB script for to draw pivot tables in Excel? Answer with example data. 2.What are the advantages of _NULL_ in Data steps? Can we use _NULL_ in Proc steps also? 3. How to call the macro variable into Data Steps? 4. Can we draw pivot tables in Excel using Proc SQL? Please post answers for the above questions with suitable examples, and how to use VB script for Excel using SAS.

1 Answers  


Explain bmdp procedure?

0 Answers  


Tell e how how dealt with..

0 Answers   Wipro,


what is picture format? give any one example?

3 Answers   Parexel,


Categories