Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to identify the minimum year of membership to the agreement between the pairs that are symmetric

    Dear All,
    I have data on trade agreements and membership to the WTO between country (i) and country (j). My data looks something like:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str3(country_i country_j) int year byte(gatt pta)
    "AUS" "BRA" 1986 0 0
    "AUS" "BRA" 1987 0 0
    "AUS" "BRA" 1988 0 1
    "AUS" "BRA" 1989 0 1
    "AUS" "BRA" 1990 0 1
    "AUS" "BRA" 1991 0 1
    "AUS" "BRA" 1992 1 1
    "AUS" "BRA" 1993 1 1
    "AUS" "BRA" 1994 1 1
    "BRA" "AUS" 1986 0 0
    "BRA" "AUS" 1987 0 0
    "BRA" "AUS" 1988 1 0
    "BRA" "AUS" 1989 1 0
    "BRA" "AUS" 1990 1 1
    "BRA" "AUS" 1991 1 1
    "BRA" "AUS" 1992 1 1
    "BRA" "AUS" 1993 1 1
    "BRA" "AUS" 1994 1 1
    end

    The gatt membership year between AUS-BRA pair is 1992 whereas between BRA-AUS pair , it is year 1988. I want to pick the minimum year (earliest year between the symmetric pairs). How can i do that in STATA ?
    similarly the pta between between AUS-BRA pair is 1988 whereas between BRA-AUS pair, the agreement year is1990. Similarily, i want to pick the minimum year of agreement signing between the country pairs which are symmetric .

    Thank you


  • #2
    Code:
    . search dm0043, entry
    
    Search of official help files, FAQs, Examples, and Stata Journals
    
    SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
            Q4/08   SJ 8(4):588--591                                 (no commands)
            tip on how to handle dyadic identifiers
    dm0043 is an otherwise unpredictable search term for many discussions here on Statalist of precisely this issue.


    Code:
    gen first = cond(country_i < country_j, country_i, country_j) 
    gen second = cond(country_i < country_j, country_j, country_i) 
    
    egen wanted = min(pta) , by(first second)
    See also https://www.statalist.org/forums/help#spelling

    Comment


    • #3
      Thanks Nick Cox

      Comment

      Working...
      X