Hi Folks,
I need to execute a macro inside data step. I made a simple example but the following error appears:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
valor_2
ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro VALOR will stop executing.
Our example is:
%global valor_final;
%macro valor (var_1, var_2);
%let valor_final=;
%do i=1 %to %eval(&var_2);
%if &i=1 %then %let valor_final = &var_2. ;
%else %let valor_final = &valor_final., &var_1. ;
%end;
%mend valor;
data test;
valor_1=90;
valor_2 = 5;
%valor(valor_1, valor_2);
var_final = SUM(&valor_final.);
run;
In this case, our objective is parameter "VALOR_FINAL" will be replace by: "90, 90, 90, 90, 90". So the program will be:
data test;
valor_1=90;
valor_2 = 5;
%valor(valor_1, valor_2);
var_final = SUM(90, 90, 90, 90, 90);
run;
Regards,
... View more