Hi all,

Working with two different datasets, and wondering if it is possible to perform rangejoin when the date range is in the using_dataset? Minimal example as follows,

Code:
ssc install dataex

clear
input byte id int(StartYear EndYear EventType) 
1 1969    1971    1  
1 1973    1980    1
2 1950    1970    1
3 1955    1970    1
4 1982    1992    1
end
save "events.dta", replace

clear
input byte id int Year 
1 1970  
1 1971  
1 1972
1 1973 
3 1970  
3 1971
end

ssc install rangejoin
ssc install rangestat
rangejoin Year StartYear EndYear using "events.dta", by(id)
This unfortunately results in the error: was expecting a numeric variable, a number, or a system missing value for the interval low: StartYear.

Desired output would actually be as follows, in which EventType is a dummy variable indicating whether an event occurred within a given year:

Code:
     

. list, sepby(id)

     +----------------------+
     | id   Year  EventType |
     |----------------------|
  1. |  1   1970          1 |
  2. |  1   1971          1 |
  3. |  1   1972          . |
  4. |  1   1973          1 |
     |----------------------|
  5. |  3   1970          1 |
  6. |  3   1971          . |
     +----------------------+
I also experimented with joinby but encountered additional errors. Any thoughts or guidance would be greatly appreciated!