By using the combination symget&put functions, as you suggested me to do, I was able to solve the problem. Thanks a lot Cynthia and everyone who tried to help me.
Here is the final version of the code:
%macro expected_future_profit(_input =,
_baseline_def =,
_baseline_attr_h =,
_baseline_attr_s =,
_nie_lkp =,
_nir_lkp =,
_losses_lkp =,
_rf =,
_output =);
* CREATE THE MACRO VARS FOR BASELINE FUNCTIONS;
data _null_;
set &_baseline_def end=no_more;
call symput('_base_def'||left(_n_), _surviv_);
if no_more then do;
call symput('count', _n_);
end;
run;
data _null_;
set &_baseline_attr_h;
call symput('_base_attr_h'||left(_n_), _surviv_);
run;
data _null_;
set &_baseline_attr_s;
call symput('_base_attr_s'||left(_n_), _surviv_);
run;
* CREATE THE MACRO VARS FOR REVENUE;
data _null_;
set &_nie_lkp;
call symput('_nie'||left(_n_), nie_avg);
run;
data _null_;
set &_nir_lkp;
call symput('_nir'||left(_n_), nir_avg);
run;
* CREATE THE MACRO VARS FOR LOSSES;
data _null_;
set &_losses_lkp;
call symput('_losses'||left(_n_), losses_avg);
run;
* EXPECTED FUTURE PROFITABILITY CALCULATION;
data &_output;
set &_input;
* RECURSIVE EQUATION;
%let count = &count;
vp = 0;
%do i = (&count-1) %to 10 %by -1;
%let iplus = %eval(&i + 1);
nie_val = symget('_nie'||left(put(&i + &count*scr_def_seg, 3.0)));
nir_val = symget('_nir'||left(put(&i + (&count*scr_def_seg), 3.0)));
losses_val = symget('_losses'||left(put(&i + (&count*scr_def_seg_roll), 3.0)));
vp = ((&&_base_attr_h&iplus/&&_base_attr_h&i)**exp(- scr_attr_h))*((&&_base_attr_s&iplus/&&_base_attr_s&i)**exp(- scr_attr_s))*
((((&&_base_def&iplus/&&_base_def&i)**exp(- scr_def))*(nir_val + nie_val + (vp/(1+&_rf))) +
(1 - (&&_base_def&iplus/&&_base_def&i)**exp(- scr_def ))*losses_val));
%end;
run;
%mend expected_future_profit;
%expected_future_profit(_input =intest,
_baseline_def = dat.baseline_def,
_baseline_attr_h = dat.baseline_attr_h,
_baseline_attr_s = dat.baseline_attr_s,
_nie_lkp = dat.nie_lkp,
_nir_lkp = dat.nir_lkp,
_losses_lkp = dat.losses_lkp,
_rf = 0,
_output = test);
... View more