Announcement

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

  • Generate destination variables in a bilateral migration database

    Hello everyone,

    I am facing the following issue :

    I have a dataset with dyadic information such as bilateral migration flows and I have monadic characteristics from the countries of origin.
    I renamed these specific monadic variables varname_o and now I want to generate variables related to the destination countries varname_d.

    My current dataset as this kind of shape :
    Orig Dest Migration flow varname1_o varname2_o
    A B 12 100 200
    A C 15 100 200
    B A 2 50 100
    C A 3 75 150

    And I am trying to obtain a dataset of this shape :
    Orign Dest Migration_flow varname1_o varname2_o varname1_d varname2_d
    A B 12 100 200 50 100
    A C 15 100 200 75 150
    B A 2 50 100 100 200
    C A 3 75 150 100 200
    If anyone has any clue to help me solve this issue, I would be very grateful.

    Thank you!



    Raphaƫl

  • #2
    A good answer to your question would substantially depend on information you have not provided, namely the structure of the file containing the data characterizing individual countries ("monadic characteristics"). For the sake of illustration, I'll assume that such information is in a separate file that contains for each observation a country identifier called "Dest" and the variables varname1, varname2, ... in wide layout. Presuming that, the relevant code would be something like this, in relation to which I'd recommend you read -help merge-:

    Code:
    use "MonadicFile.dta"
    rename (varname1 varname2 ... ) =_d  /
    keep Dest  *_d
    save "SomeNewName.dta"
    //
    use "DyadicFile.dta", clear
    merge m:1 Dest using "SomeNewName.dta"
    If you had provided example data for both files using -dataex-, per the StataList FAQ, a better answer would have been possible. In contrast to what I have assumed, I suppose it's possible you only have the monadic information of interest in the dyadic file as the varname*_o variables. If that is the case, you could do something like:
    Code:
    drop Dest
    rename Orig Dest
    rename ...  (as above)
    save ... 
    use ...
    merge ...


    Comment


    • #3
      Thank you very much Mike!
      In fact, I have the monadic information in the dyadic file, thank you for giving me a solution for this alternative scenario.

      Very kind and helpful.

      Comment

      Working...
      X