Announcement

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

  • Creating an individual level ID

    I have a dataset that identifies siblings from a survey, and another dataset with variables from wave 1 and wave 2 of that survey. The problem is that the sibling dataset contains two identifiers, aid_1 and aid_2, while the wave 1-2 dataset only contains the aid identifier. When I merged the two datasets, I encountered an issue: the individual '97570477' appears in the aid_2 variable but not in the aid variable. I would like to create a new variable that consolidates all the aid values, so every individual ID is in the same variable.
    [CODE]
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str24 aid str8 aid_2 double famid
    "93710875" "97570477" 1001
    "93576557" "97506154" 1002
    "96717912" "96717917" 1003
    "91656927" "97676522" 1004
    "91588998" "93578896" 1005
    "90718946" "91588942" 1006
    "99578364" "99578369" 1007
    "91576326" "98576229" 1008
    "93506890" "93506897" 1009
    "92544209" "96884901" 1010
    "99574220" "99574221" 1011
    "93504422" "99574221" 1011
    "93504422" "99574220" 1011
    "90571316" "91571911" 1012
    "91576322" "91576325" 1013
    "90716062" "91886961" 1014

  • #2
    I'm going to guess that what you mean by "I would like to create a new variable that consolidates all the aid values, so every individual ID is in the same variable." is this:
    Code:
    gen `c(obs_t)' obs_no = _n
    rename aid aid_1
    reshape long aid_, i(obs_no)
    rename aid_ aid

    Comment

    Working...
    X