Hi All,
I have a dataset of dyads. Each dyad is composed of two people (pids).
For each dyad, I have a measure of whether its two pids are directly
connected through a group (variable name "interlock"). I would now
like to construct another variable that measures whether the dyad has
an *indirect* tie of the first order through one of the other pids.
Here is what a sample of the data look like:
----------
clear
input dyadid pida pidb interlock indirect
1 1 2 1 0
2 1 3 0 1
3 1 4 0 0
4 2 3 1 0
5 2 4 0 1
6 3 4 1 0
end
-----------
list
Looking at the data, dyads 1, 4 and 6 contain pid's that are directly
tied to each other (i.e. interlock == 1). This creates two "indirect"
ties in the network (i.e. indirect ==1): pid's 1 and 3 have an
indirect tie through pid 2, and pid 2 and 4 have an indirect tie
through 3. My actual data consist of about 118k dyads. This is my
question: does anyone see a way I can create the variable "indirect"
through some kind of a loop, etc? I have puzzled over this for quite a
while to no resolve. Thanks in advance! Derek
+------------------------------------------+
| dyadid pida pidb interlock indirect
|------------------------------------------|
1. | 1 1 2 1 0
2. | 2 1 3 0 1
3. | 3 1 4 0 0
4. | 4 2 3 1 0
5. | 5 2 4 0 1
6. | 6 3 4 1 0
+------------------------------------------+
*
* 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/