Announcement

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

  • generating mother's columns corresponding to son/daughter id

    Dear community members,

    I need some coding help.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double IDHH int(PERSONID RO10 EDUC7) double INCOME int(RO5 ED2 ED3 MM13)
    102010101  3  2  8  176100 19 1 1 .
    102010101  4  2  5  176100 14 1 1 .
    102010101  7  6  3  176100  7 1 0 .
    102010101  8  6  0  176100  4 1 0 .
    102010101  5  2  8  176100 29 1 1 0
    102010101  1 69  0  176100 57 0 0 0
    102010101  6  .  8  176100 26 1 1 0
    102010101  2  .  0  176100 49 0 0 .
    102010101  9  6  0  176100  2 0 0 .
    102010201  4  3 12 1039150 20 1 2 .
    102010201  1 75 12 1039150 76 1 1 .
    102010201 10  8  3 1039150  8 1 1 .
    102010201  5  3  8 1039150 19 1 1 .
    102010201  2 75 15 1039150 42 1 2 0
    102010201  3  .  8 1039150 40 1 0 0
    102010201  8  . 12 1039150 33 1 1 0
    102010201 13  .  8 1039150 26 1 1 0
    102010201  6  3  5 1039150 13 1 1 .
    102010201  7 75 16 1039150 37 1 2 0
    102010201 11  8  3 1039150  6 1 1 .
    102010201 14 13  0 1039150  8 1 1 .
    102010201 12 75 16 1039150 31 1 2 0
    102010201 16  .  0 1039150 65 0 0 .
    102010201 15 13  0 1039150  3 0 0 .
    102010201  9  8  8 1039150 13 1 1 .
    102010301  6  2  8  182340 14 1 1 .
    102010301  7  2  3  182340 12 1 1 .
    102010301  3  2 10  182340 23 1 1 .
    102010301  1 75 10  182340 45 1 2 0
    102010301  5  2  8  182340 17 1 1 .
    102010301  2  .  0  182340 43 0 0 .
    102010301  4  2 12  182340 20 1 2 0
    102010401  1 69  0   90760 57 0 0 0
    102010401  4  2  8   90760 14 1 1 .
    102010401  3  2  5   90760 20 1 0 .
    102010401  2  .  0   90760 47 0 0 .
    102010401  5  2  8   90760 13 1 1 .
    102010501  3  .  0  212600 27 0 0 0
    102010501  6  .  8  212600 23 1 0 0
    102010501  2  .  0  212600 38 0 0 .
    102010501  1 75  8  212600 50 1 0 0
    102010501 10  2  3  212600 12 1 0 .
    102010501  4  .  0  212600 25 0 0 .
    102010501  7  .  8  212600 21 1 0 .
    102010501  9  2  8  212600 16 1 1 .
    102010501  5  4  0  212600  1 0 0 .
    102010501  8  2 12  212600 18 1 1 .
    102010601  3  .  0  152100 29 0 0 .
    102010601  7  .  0  152100 33 1 1 .
    102010601  1 75  0  152100 72 0 0 .
    102010601  9  7  0  152100  3 0 0 .
    102010601  2 75  0  152100 39 0 0 0
    102010601  8  7  3  152100  7 1 1 .
    102010601  6 75  0  152100 37 0 0 0
    102010601  5  3  0  152100  1 1 0 .
    102010601 11  .  8  152100 24 1 1 .
    102010601 10 75  0  152100 27 1 1 0
    102010601  4  3  0  152100  4 1 0 .
    102010701  1 69  0  104070 52 0 0 .
    102010701  2  .  0  104070 42 0 0 .
    102010701  5  2  0  104070 20 0 0 .
    102010701  4  2  8  104070 24 1 0 0
    102010701  7  2  8  104070 16 1 1 .
    102010701  3  2  0  104070 26 0 0 0
    102010701  8  2  8  104070 15 1 1 .
    102010701  6  2  0  104070 18 0 0 .
    102010801  5  2  8   15050 13 1 0 .
    102010801  8  2  0   15050  0 0 0 .
    102010801  2  .  0   15050 37 0 0 .
    102010801  4  2  8   15050 14 1 0 .
    102010801  3  2  0   15050 18 0 0 .
    102010801  6  2  0   15050 12 0 0 .
    102010801  7  2  0   15050  3 0 0 .
    102010801  1  .  0   15050 42 0 0 0
    102010901  1  .  0  174601 48 0 0 .
    102010901  2  1  8  174601 21 1 1 0
    102010901  7  1  8  174601 14 1 1 .
    102010901  3  .  8  174601 19 1 1 .
    102010901  5  1  8  174601 17 1 1 0
    102010901  4  1  3  174601 20 0 0 0
    102010901  8  1  8  174601 12 1 1 .
    102010901  6  1  8  174601 14 1 0 .
    102010902  2 69  0   25420 25 0 0 .
    102010902  3  2  0   25420  4 0 0 .
    102010902  1 69  0   25420 27 0 0 0
    102010902  4  2  0   25420  1 0 0 .
    102011001  8 13  8  271080 22 1 1 .
    102011001 10  9 10  271080 25 1 1 0
    102011001  4 13  0  271080 33 0 0 .
    102011001  5 13 10  271080 31 1 1 0
    102011001 12  9  8  271080 18 1 1 0
    102011001  6 13 10  271080 29 1 1 0
    102011001  2  . 10  271080 30 1 1 .
    102011001 13  .  5  271080 67 1 0 .
    102011001  1 13 10  271080 37 1 1 0
    102011001  7 13 10  271080 24 1 1 0
    102011001  3  2  0  271080  3 0 0 .
    102011001  9  .  0  271080 45 0 0 .
    102011001 11  9 12  271080 19 1 2 .
    102011101  3  2  8   51670 11 1 1 .
    end
    label values RO10 RO10
    label def RO10 69 "IF Spouse/Parent outside for more than 6 months", modify
    label def RO10 75 "Dead", modify
    label values EDUC7 EDUC7
    label def EDUC7 0 "none 0", modify
    label def EDUC7 3 "1-4 3", modify
    label def EDUC7 5 "primary 5", modify
    label def EDUC7 8 "6-9 8", modify
    label def EDUC7 10 "Secondary(&11) 10", modify
    label def EDUC7 12 "Higher sec(&13,14) 12", modify
    label def EDUC7 15 "graduate 15", modify
    label def EDUC7 16 "some post-grad 16", modify
    label values ED2 ED2
    label def ED2 0 "No 0", modify
    label def ED2 1 "Yes 1", modify
    label values ED3 ED3
    label def ED3 0 "none", modify
    label def ED3 1 "Little 1", modify
    label def ED3 2 "Fluent 2", modify
    label values MM13 MM13
    label def MM13 0 "No 0", modify

    Here IDHH is unique household id, PERSONID is the household id of persons, RO10 is the household id of the mother of the person, and other characteristic variables associated to persons. Is it possible to paste mothers' characteristics (EDUC7 INCOME RO5 ED2 ED3 MM13) against son/daughters' PERSONID.

    regards,
    ajay

  • #2
    RO10 is the household id of the mother of the person
    No, that's not true. The household IDs are 9 digit numbers, and the RO10 values are small numbers. I think you meant that the RO10 values are the PERSONID of the mother's person, presumably to be applied within the same household. I also note that RO10 values 69 and 75 imply that no mother is in the household.

    Code:
    frame copy default mom_data
    frame mom_data: rename (EDUC7 INCOME RO5 ED2 ED3 MM13) mom_=
    frlink m:1 IDHH RO10, frame(mom_data IDHH PERSONID)
    replace mom_data = . if inlist(RO10, 69, 75)
    frget mom_*, from(mom_data)
    drop mom_data
    frame drop mom_data


    Comment


    • #3
      Sir, you are right. Indeed, RO10 is person id within the household. Thank you very much for helping with the code.

      Comment

      Working...
      X