For SAS Viya users, here are two other potential solutions:

1. CASL execute() function

The is a CASL Built-in function that compiles and executes CASL code. For this example, I create data set "a" in CASUSER (the CAS version of the WORK library), and I replace the &MVAR macro variable reference with MVAR, where MVAR is a CASL variable that is set to the current value of the macro variable at run time. Using PROC CAS, CAS table "a" is pulled into a result table, which is iterated over using execute() to evaluate the expression.

data casuser.a;
length a b 8 c $ 255;
a=3; b=4; c='a**2+b**2'; output;
a=7; b=22; c='b/a * MVAR'; output; /* Replaced &MVAR with MVAR */
a=113; b=355; c='cos(b/a)'; output;
a=0; b=1; c='cdf("NORMAL", 0, a, b)'; output;
run;

%let MVAR=2;

proc cas;
table.fetch result=r / table="a";
table_a = r.Fetch;
table_b = newtable("table_b", {'a','b','c','d'}, {'double','double','string','double'});

MVAR = symget('MVAR');

do row over table_a;
a=row.a;
b=row.b;
execute('d='||row.c||';');
row = {row.a, row.b, row.c, d};
addrow(table_b, row);
end;

saveresult table_b dataout=work.b;
quit;

proc print data=b;run;

2. PROC PYTHON

If enabled, Viya users can insert Python code directly into SAS programs. For the "a" data set I again replace &MVAR with MVAR, a Python variable set to the current value of the macro variable at run time. Also, the trigonometric and probabilistic SAS functions are replaced with Python equivalents. Using PROC PYTHON, data set "a" is pulled into a DataFrame, which it iterated over using eval() to evaluate the expression.

data a;
length a b 8 c $ 255;
a=3; b=4; c='a**2+b**2'; output;
a=7; b=22; c='b/a * MVAR'; output; /* Replaced &MVAR with MVAR */
a=113; b=355; c='math.cos(b/a)'; output; /* Replaced SAS function with Python equivalent */
a=0; b=1; c='norm.cdf(0,loc=a,scale=b)'; output; /* Replaced SAS function with Python equivalent */
run;

%let MVAR=2;

proc python;
submit;

import pandas
import math
from scipy.stats import norm

MVAR = float(SAS.symget('MVAR')) # Get the value of MVAR macro variable
df = SAS.sd2df('work.a') # Pull data set "a" into a dataframe
df['MVAR'] = MVAR

for (i, a, b, c, MVAR) in zip(df.index, df.a, df.b, df.c, df.MVAR):
df.at[i,'d'] = eval(c)

ds = SAS.df2sd(df, 'work.b (drop=MVAR)') # Write dataframe back to data set "b"

endsubmit;
run;

proc print data=b;run;