Hello all,
My sample data is shown below:
I have variables for group, date1, date2, and ID. We can think of date1 as a start date and date2 as an end date. I want to order the dates based on the previous end date. For example, the first observation has 01jan2004 as date1 and 18jan2005 as date2. The next observation should be 19jan2005 (date1) and 03jul2005 (date2). There is a catch, however. I only want to continue this sequence if ID==1. If ID==2 or ID==3, the sequence ends and restarts based on a new ordering of dates.
I would appreciate any assistance!
Thanks,
Anoush K.
My sample data is shown below:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(group date1 date2) byte ID 1 16071 16454 1 1 16305 16620 2 1 16455 16620 2 1 16455 16620 2 1 16455 16620 2 1 16742 16818 1 1 16742 16860 2 1 16742 16860 3 1 16742 17044 2 1 16819 17166 2 1 16819 17166 2 1 16819 17166 2 1 16966 17166 2 1 16966 17166 2 1 17167 17911 2 end format %td date1 format %td date2
I would appreciate any assistance!
Thanks,
Anoush K.

Comment