That code was written a while ago, and it's fairly lengthy and does a bunch of things. So rather than trying to adapt it to your situation, I think you are better off with some very simple code starting from scratch:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id double(noi_start noi_end) 1 12 26 1 32 36 2 5 20 3 7 15 4 9 20 4 30 40 4 40 45 5 3 6 5 10 15 6 2 36 7 17 19 8 15 24 end by id (noi_start), sort: gen spell = sum(_n == 1 | noi_start > noi_end[_n-1]) collapse (min) noi_start (max) noi_end, by(id spell)
Comment