merge by range in data.table

datatable

#1

I need to merge two data by range in data.table. The sas code is as below.

mydatac as c inner join mydated as d on d.gvkey=c.gvkey and

      intnx('month', datadate, -24, 'e')<c.date<=intnx('month', datadate, 12, 'e');\

#2

data.table has at least two excellent tools for this: