11-25-2014 06:48 PM
I have a panel dataset with fiscal year end dates. The second dataset is a cross-sectional one with bond issue dates.
Now, I would like to merge the first with the second based on this criterion:
The first would be matched with the second based on id(cnum and new_cusip) of course. However, the date matching criterion is that the fiscal year end date matches with the first bond issue date that occurs after the fiscal year end date.
I would appreciate any idea. I have attached two sample datasets.
12-04-2014 10:38 PM
Sure, try this:
create table set3 as
sasforum.set1 as a left join
intnx("YEAR", issue_date, -1, "END") as DATADATE,
group by newcusip, calculated DATADATE
having newcusip = min(newcusip) ) as b
on a.cnum=b.newcusip and a.DATADATE=b.DATADATE;
Replace left join with inner join if you want only the matching cases.