data table_1;
informat loan_date ddmmyy10.;
format loan_date ddmmyy10.;
input cusp loan_date loan_amount;
cards;
10222 12/06/2011 300000
10222 17/01/2012 700000
10222 18/03/2013 500000
10333 05/09/2011 60000
10333 08/10/2013 560000
10333 18/10/2015 40000
;;;
data table2;
informat fy_end_date ddmmyy10.;
format fy_end_date fy_beg_date ddmmyy10.;
input cusp fy_end_date Fyear;
fy_beg_date = intnx('year',fy_end_date,-1,'same');
cards;
10222 31/03/2011 2010
10222 31/03/2012 2011
10222 31/03/2013 2012
10222 31/03/2014 2013
10333 31/01/2012 2011
10333 31/01/2013 2012
10333 31/01/2014 2013
10333 31/01/2015 2014
;;;
run;
proc sql;
create table table3 as
select a.*,b.Fyear,b.fy_end_date from
table_1 a,
table2 b
where a.cusp = b.cusp
and a.loan_date > b.fy_beg_date
and a.loan_date <= b.fy_end_date
;
quit;
... View more