Dear All, I have this dataset
For each `id', I'd like to define a dummy variable, say `d', which is 1 if the year is between (including) `start' and `end'. For instance, for id=1101 (no overlapping years), d=1 if the year is 2004,2005,...,2009, 2018,2019,...,2013. In contrast, for id=1102, there are some overlapping years. It can be seen that, d=1 for years 2008,2009,...,2023. Any suggestions. Thanks.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(id start end) 1101 2004 2009 1101 2018 2023 1102 2008 2013 1102 2011 2016 1102 2011 2016 1102 2013 2018 1102 2018 2023 end
Comment