Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Robert Picard <picard@netbox.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: RE: Transform source table to edgelist (or nodelist) |

Date |
Mon, 20 Feb 2012 11:34:25 -0500 |

A list of all connected managers can be generated directly using the -joinby- command: *----------- begin example ------------- version 12 clear input fid str1 mid 1 A 1 B 1 C 2 A 2 B 2 D end tempfile main save "`main'" * within each firm, form all pairwise combinations of managers use "`main'" rename mid mid2 joinby fid using "`main'" list fid mid mid2, noobs sepby(mid2) * reduce to connected managers list sort mid mid2 by mid mid2: keep if _n == 1 drop if mid2 <= mid list mid mid2, noobs sepby(mid) tempfile connect save "`connect'" * to get a complete list of all possibilities * form all pairwise combinations of managers use "`main'", clear keep mid sort mid by mid: keep if _n == 1 tempfile mgrs save "`mgrs'" rename mid mid2 cross using "`mgrs'" sort mid mid2 list mid mid2, noobs sepby(mid) drop if mid2 <= mid * final list merge 1:1 mid mid2 using "`connect'" gen connect = _merge == 3 sort mid mid2 list mid mid2 connect, noobs sepby(mid) *------------ end example -------------- On Mon, Feb 20, 2012 at 7:25 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > Sorry, no; that's a different problem. > > Nick > n.j.cox@durham.ac.uk > > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox > Sent: 20 February 2012 10:54 > To: 'statalist@hsphsun2.harvard.edu' > Subject: st: RE: Transform source table to edgelist (or nodelist) > > This looks like an FAQ > > http://www.stata.com/support/faqs/data/pairs.html > > although I suspect there is a less clumsy way to approach it. > > Nick > n.j.cox@durham.ac.uk > > Steve Sauerwald > > I have a source table that contains manager/firm information. A > manager can work for M companies and a company can have N managers. > For instance, the following table shows 2 firms (FID 1 and 2) and four > managers (MID A, B, C, and D). > > FID MID > 1 A > 1 B > 1 C > 2 A > 2 B > 2 D > > Now, I'd like to create the interlocking relationships between managers. If > two managers work together in the same firm (or in more than one > firm), this would indicate a "1." If not, a "0." The end result should > be an adjacency matrix but I'd be happy to get to an edgelist first > such as the following: > > MID1 MID2 CONNECT > A B 1 > A C 1 > A D 1 > B C 1 > B D 1 > C D 0 > > Based on the information in the source table, manager C and manager D > are not connected in either firm 1 or 2, hence the 0. My actual source > table contains quite a few records so it would be great to automate > this process. Does anyone have an idea of how to implement this in > Stata? > > Alternatively, the UCLA Stata website > (http://www.ats.ucla.edu/stat/stata/code/adj_matrix.htm) shows some > code to transform a nodelist into an adjacency matrix (If someone > knows a way to transform my source table into a nodelist, that'd be > also a great help). > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: RE: RE: Transform source table to edgelist (or nodelist)***From:*Steve Sauerwald <steve.sauerwald@utdallas.edu>

**References**:**st: Transform source table to edgelist (or nodelist)***From:*Steve Sauerwald <steve.sauerwald@utdallas.edu>

**st: RE: Transform source table to edgelist (or nodelist)***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: RE: RE: Transform source table to edgelist (or nodelist)***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: SV: RE: linear approximation - impute "missing" years** - Next by Date:
**Re: st: Converting annual data to quarterly data** - Previous by thread:
**st: RE: RE: Transform source table to edgelist (or nodelist)** - Next by thread:
**Re: st: RE: RE: Transform source table to edgelist (or nodelist)** - Index(es):