# st: Re: comparing across observations and variables

 From "Martin Weiss" To Subject st: Re: comparing across observations and variables Date Thu, 9 Apr 2009 22:50:20 +0200

```<>

```
As for the first part: the one firm in the last column that appears only once in the dataset has got to be the ultimate one in the pyramid, is that right? If so, -count- it:
```

****
clear*

inp str2 firm str2 parent  str2 ultimate_parent
A A1 A2
A1 A1 A1
A3 A4 A
end

levelsof ultimate_parent, local(mylevels)

stack  firm parent ultimate_parent, into(countvar) clear

foreach lev of local mylevels{
qui cou if countv=="`lev'"
di in red "`lev' " `r(N)'
}

****

HTH
Martin
_______________________
```
----- Original Message ----- From: "Dalhia" <ggs_da@yahoo.com>
```To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, April 09, 2009 10:33 PM
Subject: st: comparing across observations and variables

```
```hi,
```
I have two sets of data: data about control relationships between firms (firm, parent firm, ultimate parent firm) and alliances between firms. I need a way to figure out who is at the top of the control pyramid using the first set of data, and then, in the alliance data, replace all firms lower down on the control pyramid with the firm at the top of the control pyramid.
```
```
1) For instance, my data about control relations between firms is shown below. I need a way to automatically figure out that A2 is at the top of this control pyramid.
```
firm, parent, ultimate parent
A, A1, A2
A1, A1, A1
A3, A4, A

2) My data about alliances between firms is shown below:

Participant 1, Participant2
A, B
A3, C
A1, D

```
3) I need to incorporate the data about control relationships (A2 is at the top of the control pyramid involving A, A1 A3, A4) in the data about alliances so that my alliance file looks like this:
```A2, B
A2, C
A2, D

I will be very grateful for any ideas you can suggest to do the above.
thanks so much
dalhia

*
*   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/
```