Dear All, I found this question somewhere, and appreciate if anyone can give some suggestions. The data is
For each id, I'd like to calculate the time between any -ymd- (I have done: sort id ymd). For instance, for id=1, I need to calculate times between any combinations of ymd, i.e., 2008.12.15-2008.10.01; 2009.01.10-2008.10.01; 2009.05.01-2008.10.01; 2009.01.10-2008.12.15; 2009.05.01-2008.12.15; and 200.05.01-2009.01.10). If the maximum time gap is falling between 30-365 (in terms of days), then this id is what I want. Any suggestions?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id str12 ymd float n 1 "2008.10.01" 1 1 "2008.12.15" 2 1 "2009.01.10" 3 1 "2009.05.01" 4 2 "2008.08.15" 1 2 "2008.10.01" 2 2 "2008.12.15" 3 2 "2008.12.31" 4 2 "2009.01.31" 5 2 "2009.05.31" 6 2 "2009.08.31" 7 end
Comment