Suppose I allow user to write his own variable calculation macro using a common user interface:
%macro calculate(var_name, var_value);
%* Some user-defined calculation;
%mend calculate;
Then in a data step, I can calculate a new variable using the user-defined macro:
data dataset;
set dataset;
new_var = %calculate('variable1', variable1); * This doesn't work. It just shows my indication.
run;
Where variable1 is a variable in dataset. Here, I want to pass in the variable name and the actual value of the variable. After the calculation, put the value in new_var.
How can I achieve this?