Statalist


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

st: comparison within panel and across time


From   joe j <[email protected]>
To   [email protected]
Subject   st: comparison within panel and across time
Date   Thu, 26 Nov 2009 16:49:07 +0100

This is a follow up of some issues resolved here a while ago.

I have a data set of firms and their partnerships over time. I want to
create a variable, which takes a value 1 if two conditions are met (1)
 the firm has partnered with “at least one” firm from a particular
country (e.g. US) in the current year and (2) the same two firms have
partnered in “at least one”  of the previous five years. One of the
challenges is that one firm may have many partnerships in a given
year, which makes using time series operators (e.g. lag/lead operator)
difficult (tsset warns: “repeated time values within panel”).

The data has four variables: 1. partnership ID, 2. year, 3. firm ID,
and 4. nation ID (an example is shown below).

The new column I want to create is “past experience with US firms” In
the year 1995 in “past experience with US firms”,  firm 4 (which is a
UK firm) gets a value 1 because it currently has a US partner (firm 2,
as well as 3) and the two had a partnership in 1992 (an example of
final result is shown at the end).

I guess the main problem I face is getting right the comparison across
the current and previous years. Any suggestion would be appreciated.

Joe

clear
inp byte(partnership) year  /*
*/ str10(firm nation), auto
28 1995  "4"   "UK"
28 1995  "2"   "US"
28 1995  "3"   "US"
21 1995  "4"   "UK
21 1995  "1"   "UK"
24 1995  "3"   "US"
24 1995  "2"   "US"
19 1994  "6"   "NL"
19 1994  "4"   "UK"
19 1994  "5"   "CH"
20 1994  "7"   "NL"
20 1994  "5"   "CH"
20 1994  "11"   "NL"
20 1994  "9"   "UK"
11 1993  "2"   "US"
11 1993  "1"   "UK"
14 1993  "3"   "US"
14 1993  "9"   "UK"
18 1993  "8"   "US"
18 1993  "9"   "UK"
18 1993  "3"   "US"
9 1992  "7"   "NL"
9 1992  "4"   "UK"
9 1992  "2"   "US"
10 1992  "5"   "CH"
10 1992  "4"   "UK"
10 1992  "6"   "NL"
10 1992  "7"   "NL"
10 1992  "1"   "UK"
10 1992  "3"   "US"
1 1991  "2"   "US"
1 1991  "4"   "UK"
1 1991  "3"   "US"
4 1991  "3"   "US"
4 1991  "4"   "UK"
4 1991  "5"   "CH"
end

The final result (last column) for 1995 and 1994, for example, would look like:

28 1995  "4"   "UK"   1  /*4&2 partnered in 1992, as well as in 1991.
see partnership ids 9 &  1*/
28 1995  "2"   "US"   1  /*2&3 partnered in 1991. see partnership id 1*/
28 1995  "3"   "US"   1
----------------------------
21 1995  "4"   "UK    1
21 1995  "1"   "UK"   0
----------------------------
24 1995  "3"   "US"   1
24 1995  "2"   "US"   1
----------------------------
19 1994  "6"   "NL"   0 /*in 1994 there are no partnerships involving US firms*/
19 1994  "4"   "UK"  0
19 1994  "5"   "CH"  0
----------------------------
20 1994  "7"   "NL"   0
20 1994  "5"   "CH"   0
20 1994  "11"   "NL"  0
20 1994  "9"   "UK"  0

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



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