Announcement

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

  • How to match same state codes based on ID variable in Panel data?

    Hi,

    I have an unbalanced panel running for the years 2010 and 2014 to 2019. The state id variable only exists for the 2010 round. However, I wanted to know how by ID variable I could also match for the rounds. I can use gen but with a large sample size the process is proving too tedious.

    The 2010 round snippet:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 Year double id byte A_Itm8
    "2010" 86755  4
    "2010" 15710 28
    "2010" 67467  7
    "2010" 69627  2
    "2010" 72779 12
    "2010" 92058 27
    "2010" 62018 18
    "2010" 16170  1
    "2010" 51619  5
    "2010" 21597  2
    "2010" 63633 24
    "2010" 15360 10
    "2010" 63749 39
    "2010" 76556 20
    "2010" 20242  7
    "2010" 65303 22
    "2010" 34734 20
    "2010" 66715  7
    "2010" 64748 15
    "2010" 37985  3
    "2010" 91487 24
    "2010" 56229  6
    "2010" 10244  9
    "2010" 94391  9
    "2010" 15897  6
    "2010" 59803 26
    "2010" 71865 21
    "2010" 66877  7
    "2010" 69416 21
    "2010" 33259  1
    "2010" 65967  1
    "2010" 71779 22
    "2010" 90860 18
    "2010" 10411  9
    "2010" 63985 21
    "2010" 22046 22
    "2010" 12668 19
    "2010" 12592 19
    "2010" 39491 10
    "2010" 12486 18
    "2010" 67955  1
    "2010" 24357 26
    "2010" 20165 17
    "2010" 17684  9
    "2010" 20682  6
    "2010" 92917 10
    "2010" 93497 12
    "2010" 38483 12
    "2010" 23320 22
    "2010" 76483 10
    "2010" 67846  2
    end
    The other rounds
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 Year double id
    "2017" 100001
    "2018" 100001
    "2016" 100001
    "2019" 100001
    "2014" 100001
    "2015" 100001
    "2016" 100002
    "2014" 100002
    "2019" 100002
    "2017" 100002
    "2018" 100002
    "2015" 100002
    "2016" 100003
    "2015" 100003
    "2019" 100003
    "2014" 100003
    "2017" 100003
    "2018" 100003
    "2019" 100004
    "2016" 100004
    "2018" 100004
    "2017" 100004
    "2015" 100004
    "2014" 100004
    "2018" 100005
    "2014" 100005
    "2017" 100005
    "2015" 100005
    "2016" 100005
    "2019" 100005
    "2017" 100006
    "2018" 100006
    "2015" 100006
    "2014" 100006
    "2016" 100006
    "2019" 100006
    end

  • #2
    Perhaps you could
    1. Create a dataset only with panel ID and State, dropping any duplicates
    2. merge this smaller dataset to all other datasets using ID s the merging variable (merge m:1 panelid using state_id),

    Comment


    • #3
      FernandoRios Hi, I have tried it out. It just creates adds the observations and the state variable. The codes don't code assigned.

      Comment

      Working...
      X