Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Robert Picard <picard@netbox.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: Social Network Analysis shortest path centrality |
Date | Sun, 1 Sep 2013 16:44:03 +0100 |
There is indeed a problem in merging the list with itself as it leads to many-to-many merges and I have yet to see one case where an m:m merge is useful. You can however use -joinby- to perform what you intuitively would want -merge- to do in this case. * --------------------- begin example --------------------- clear input source target 1 2 1 5 1 6 1 9 2 3 2 5 2 7 5 8 5 6 8 9 end tempfile main save "`main'" * make sure the data has no duplicates isid source target rename source co local i 0 local more 1 while `more' { local ++i rename target source joinby source using "`main'", unmatched(master) drop _merge rename source level`i' sort co level`i' by co level`i': gen one = _n == 1 & !mi(level`i') by co: egen connect`i' = total(one) drop one count if !mi(target) local more = r(N) } drop target sort co level* order co level* connect* list, sepby(co) noobs * --------------------- end example ----------------------- Original message follows: st: Social Network Analysis shortest path centrality