merge by range in data.table

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');\

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

1 Like