This code takes two macros and assigns them to arrays inside a data step, then loops through each variable defined in ln_vars, creating a new variable which is the natural log of the variable, appending _ln to the name
%let ln_vars = var1 var2;
%let ln_names = %add_string(&ln_vars, _ln);
data transform;
set analysis;
array ln &ln_vars;
array ln_n &ln_names;
*call execute ('%add_string(%str(&ln_vars), _ln)');
do over ln;
ln_n = log(ln);
end;
run;
maybe there's a better idiom in sas code (I hope). I want to be able to just pass a single macro (the ln_vars macro) and call the %add_string() function from inside the data step. The commented 'call execute' returns the correct string, but when I try to
1588 array ln_n call execute ('%add_string(%str(&ln_vars), _ln)');
ERROR: Attempt to initialize variable call in numeric array ln_n with character constant
'%add_string(%str(&ln_vars), _ln)'.