The code below is returning the following error message:
Syntax error, expecting one of the following: a name, INPUT, PUT.
%macro run_calculation(amt, t, r);
data customer_value;
i=&r./100.;
do n=0 to t;
S=&amt.*[(1+ calculated i)^t - 1]/calculated i
end;
run;
%mend;
%run_calculation(amt=1000, t=8, r=5);
Expected output is S value at each t in a table.
Few comments:
;
when assigning S.calculated i
, use i
directly.**
and not ^
.t
instead of the macro-variable &t.
in the do loop statement.n
, not t
so you need to use n
in your formula.%macro run_calculation(amt, t, r);
data customer_value;
i=&r./100.;
do n=0 to &t.;
S=&amt.*((1+i)**n - 1)/i;
output;
end;
run;
%mend;
%run_calculation(amt=1000, t=8, r=5);
i n S
0.05 0 0
0.05 1 1000
0.05 2 2050
0.05 3 3152.5
0.05 4 4310.125
0.05 5 5525.63125
0.05 6 6801.9128125
0.05 7 8142.0084531
0.05 8 9549.1088758