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 |
What are the data types that sas contain?
What is the basic syntax of a sas program?
how to rearrange the data as our wish by using dataset block?
How do you add a number to a macro variable?
How would you code the criteria to restrict the output to be produced?
why a stop statement is needed for the point= option on a set statement?
What is SAS informats?
how do you validate tables abd reports?
2 Answers Accenture, Quintiles,
calculate the sum of value using only DATA STEP. data count_; input year name $ value; cards; 2006 xxx 10 2007 yyy 12 2006 xxx 20 2008 yyy 15 2007 xxx 15 ; out put should be like this year name T_value ----------------------- 2006 xxx 30 2007 xxx 15 2007 yyy 12 2008 xxx 15
Can you execute a macro within a macro? Describe. : sas-macro
What are the ways in which macro variables can be created in sas programming?
Describe the function and untility of the most difficult SAS macro that you have written.