Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: re: Combining consecutive records if matching conditions


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: re: Combining consecutive records if matching conditions
Date   Mon, 12 Mar 2007 15:33:57 -0000

Good question. Within each group, 

bysort group (beg) : gen disjoint = sum(beg != end[_n-1]) 

should divide into distinct groups of segments. 

You then look for -duplicates- on -group- and -disjoint-. 

Nick 
[email protected] 

Biernbaum, Lee
 
> Thanks for your help. I think this will definitely get me on the right
> track. One followup though:
> 
> How do I ensure that the segments are, in fact, end-to-end? 
> That is, it
> is not difficult to foresee a situation where
> 
> Segment 1
> Beg = 1.00 end = 1.07
> 
> Segment 2
> Beg = 1.07 end = 1.25
> 
> Segment 9
> Beg = 2.97 end = 3.14
> 
> And they match on all the other key variables (surface width, road id,
> etc). In this situation, Segments 3-8 may or may not exist in the
> database, but, even if they do, they do not match on the
> characteristics.
> 
> In this case, Segments 1 and 2 should be combined but segment 
> 3 left on
> its own.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index