So I have the following code: %let n_periods=5;
data table1;
input start : MMDDYY10. end : MMDDYY10. c_date : MMDDYY10.;
format start end c_date MMDDYY10.;
datalines;
1/1/2016 12/31/2016 12/31/2016
7/1/2016 6/30/2017 12/31/2016
7/1/2015 6/30/2016 12/31/2016
7/1/2015 6/30/2018 12/31/2016
7/1/2013 6/30/2023 12/31/2016
9/1/2010 10/31/2020 12/31/2016
7/1/2017 6/30/2018 12/31/2016
3/1/2008 2/28/2009 12/31/2016
1/1/2013 12/31/2013 12/31/2016
9/1/2011 10/31/2012 12/31/2016
;
run;
data periods (drop=_i);
set table1;
array per[&n_periods.];
do _i = 1 to &n_periods.;
per[_i] = c_date-365*_i;
end;
run;
proc iml;
start factor_dev(start_dt,end_dt,c_date);
accrued=c_date-start_dt;
duration=end_dt-start_dt;
if accrued/duration>1 then do ;
factor_dev=1;
end;
else if accrued/duration<0 then do;
factor_dev=0;
end;
else if accrued/duration then do;
factor_dev=accrued/duration;
end;
return (factor_dev);
finish;
periods=j(10,3,0);
use periods;
read all var _all_ into periods;
close periods;
factor_dev_acu=j(dimension(periods)[1,1],&n_periods.,0);
print periods;
do i=1 to dimension(periods)[1,1];
do j=1 to &n_periods.;
factor_dev_acu[i,j]=factor_dev(periods[i,1],periods[i,2],periods[i,j+2]);
end;
end;
print factor_dev_acu; When I run it, I get the "ERROR: (execution) Matrix has not been set to a value." error. The problem appears to be in line 64. I can't find the reason why it's not accepting the third parameter, if I change it to periods[i,3] The program executes without errors, but I can't seem to be able to use anything other than number constants. Any idea on what I'm doing wrong?
... View more