Announcement

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

  • Panel Data - adding information from observations of parents to children

    Hi all,

    I have a question regarding a long panel set I am using.

    I have variables for household (IDHH), individual ID (HHPBASE), the survey (whether it was round 1 or round 2), PBASE (the id number of the individual within the household), RO8 (father's ID), RO9 (mother's ID), and ED6 (years of education) as below - there are a lot more variables in this and I will want to map other variables, not just years of education, but for illustration purposes I have provided the following from the data set:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str10 IDHH double HHPBASE int(SURVEY PBASE RO8 RO9 ED6)
    "010201010"  101020101001 1  1  2  .  0
    "010201010"  101020101002 1  2  1  .  0
    "010201010"  101020101003 1  3  .  1  8
    "010201010"  101020101005 1  5  .  1  7
    "010201010"  101020101006 1  6  .  1  2
    "010201020"  101020102001 1  1  2  . 10
    "0102010201" 101020102001 2  1 75 75 12
    "010201020"  101020102003 1  3  4  1 15
    "0102010201" 101020102003 2  3  3  1 15
    "010201020"  101020102004 1  4  3  .  0
    "0102010201" 101020102004 2  4  2  .  8
    "010201020"  101020102005 1  5  .  3  7
    "0102010201" 101020102005 2  5  .  2 12
    "010201020"  101020102006 1  6  .  3  3
    "0102010201" 101020102006 2  6  .  2  8
    "010201020"  101020102007 1  7  .  3  0
    "0102010201" 101020102007 2  7  .  2  5
    "010201020"  101020102008 1  8  9  1 15
    "0102010201" 101020102008 2  8  8  1 15
    "010201020"  101020102009 1  9  8  . 12
    "0102010201" 101020102009 2  9  7  . 12
    "010201020"  101020102010 1 10  .  8  2
    "0102010201" 101020102010 2 10  .  7  6
    "010201020"  101020102011 1 11  .  8  0
    "0102010201" 101020102011 2 11  .  7  2
    "010201020"  101020102012 1 12 13  1 15
    "0102010201" 101020102012 2 12 13  1 15
    "010201020"  101020102013 1 13 12  . 12
    "0102010201" 101020102013 2 13 12  .  7
    "010201020"  101020102014 1 14  . 12  0
    "0102010201" 101020102014 2 14  . 12  0
    "010201020"  101020102015 1 15  .  .  0
    "0102010201" 101020102015 2 15  .  .  0
    "010201030"  101020103001 1  1  2  .  9
    "0102010301" 101020103001 2  1  2 69 10
    "010201030"  101020103002 1  2  1  .  0
    "0102010301" 101020103002 2  2  1  .  0
    "010201030"  101020103003 1  3  .  1  9
    "0102010301" 101020103003 2  3  .  1 11
    "010201030"  101020103004 1  4  .  1  6
    "0102010301" 101020103004 2  4  .  1 12
    "010201030"  101020103005 1  5  .  1  5
    "0102010301" 101020103005 2  5  .  1  9
    "010201030"  101020103006 1  6  .  1  1
    "0102010301" 101020103006 2  6  .  1  6
    "010201030"  101020103007 1  7  .  1  0
    "0102010301" 101020103007 2  7  .  1  4
    "010201040"  101020104001 1  1  2  .  0
    "0102010401" 101020104001 2  1  2 75  0
    "010201040"  101020104002 1  2  1  .  0
    "0102010401" 101020104002 2  2  1  .  0
    "010201040"  101020104003 1  3  .  1  6
    "0102010401" 101020104003 2  3  .  1  5
    "010201040"  101020104004 1  4  .  1  1
    "0102010401" 101020104004 2  4  .  1  7
    "010201040"  101020104005 1  5  .  1  0
    "0102010401" 101020104005 2  5  .  1  6
    "010201050"  101020105002 1  2  3  1  0
    "0102010501" 101020105002 2  2  2 75  8
    "010201050"  101020105003 1  3  2  .  0
    "0102010501" 101020105003 2  3  1  .  0
    "010201050"  101020105006 1  6  .  2  0
    "0102010501" 101020105006 2  6  4  1  0
    "010201050"  101020105007 1  7  .  2  8
    "0102010501" 101020105007 2  7  7  1  9
    "010201050"  101020105008 1  8  .  2  5
    "0102010501" 101020105008 2  8  .  1 12
    "010201050"  101020105009 1  9  .  2  4
    "0102010501" 101020105009 2  9  .  1  9
    "010201050"  101020105010 1 10  .  2  0
    "0102010501" 101020105010 2 10  .  1  4
    "010201060"  101020106001 1  1 75  .  0
    "0102010601" 101020106001 2  1 75 75  0
    "010201060"  101020106012 1 12  .  1  0
    "0102010601" 101020106012 2 12  3  1  0
    "010201060"  101020106013 1 13 14  1  0
    "0102010601" 101020106013 2 13  7  1  0
    "010201060"  101020106014 1 14 13  .  0
    "0102010601" 101020106014 2 14  6  .  0
    "010201060"  101020106015 1 15  .  1  0
    "0102010601" 101020106015 2 15 11  1  0
    "010201070"  101020107001 1  1  2  .  0
    "0102010701" 101020107001 2  1  2 75  0
    "010201070"  101020107002 1  2  1  .  0
    "0102010701" 101020107002 2  2  1  .  0
    "010201070"  101020107003 1  3  .  1  0
    "0102010701" 101020107003 2  3  .  1  0
    "010201070"  101020107004 1  4  .  1  7
    "0102010701" 101020107004 2  4  .  1  8
    "010201070"  101020107006 1  6  .  1  0
    "0102010701" 101020107006 2  6  .  1  0
    "010201070"  101020107007 1  7  .  1  0
    "0102010701" 101020107007 2  7  .  1  0
    "010201070"  101020107008 1  8  .  1  1
    "0102010701" 101020107008 2  8  .  1  9
    "010201070"  101020107009 1  9  .  1  1
    "0102010701" 101020107009 2  9  .  1  9
    "010201080"  101020108001 1  1  2  .  0
    "0102010801" 101020108001 2  1  2  .  0
    "010201080"  101020108002 1  2  1  .  0
    end
    label values SURVEY SURVEY
    label def SURVEY 1 "IHDS1 1", modify
    label def SURVEY 2 "IHDS2 2", modify
    label values RO8 RO8
    label def RO8 75 "Died 75", modify
    label values RO9 RO9
    label def RO9 69 "Other nonres 69", modify
    label def RO9 75 "Died 75", modify
    label values ED6 ED6
    label def ED6 0 "none, <1 0", modify
    label def ED6 1 "1st class 1", modify
    label def ED6 2 "2nd class 2", modify
    label def ED6 3 "3rd class 3", modify
    label def ED6 4 "4th class 4", modify
    label def ED6 5 "5th class 5", modify
    label def ED6 6 "6th class 6", modify
    label def ED6 7 "7th class 7", modify
    label def ED6 8 "8th class 8", modify
    label def ED6 9 "9th class 9", modify
    label def ED6 10 "Secondary 10", modify
    label def ED6 11 "11th Class 11", modify
    label def ED6 12 "High Secondary 12", modify
    label def ED6 15 "Bachelors 15", modify
    What I am attempting to do here is to, for each observation, add the education levels of the mother and father. Ultimately, I will want to run a regression where the outcome variable is child's education, and I want to control for parent's education. Of course, I understand that this will reduce the number of observations, but that is fine as I am interested in the younger generations cohabiting with their parents, in which case the data should be present for all individuals.

    What would be the best way to do this?

    Thanks in advance!
    Sanchit

  • #2
    Well, either I'm misunderstanding your explanation of the data or there is something seriously wrong with your data. Let's look at IDHH 010201010 in round 1. PBASE 1 has PBASE 2 as his father, but PBASE 2 has PBASE 1 as his father. So PBASE 1 and PBASE 2 are each the father of the other. That can't possibly be right.

    Also your variables R08 and R09 also contain special values referring to things like "Died 75" and "Other nonres 69." That is one of the most bizarre conflations of unrelated information in the same variable I have ever seen and I cannot believe you will get through much analysis of this data without all sorts of strange errors cropping up as a result of that. I strongly recommend replacing those by missing values and, if the information about Died 75 or Other nonres 69 is important, create new variables to indicate those conditions.

    Anyway, assuming that the data are messed up and that your description of it is correct, the following code, when supplied with correct data, would work
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear*
    input str10 IDHH double HHPBASE int(SURVEY PBASE RO8 RO9 ED6)
    "010201010"  101020101001 1  1  2  .  0
    "010201010"  101020101002 1  2  1  .  0
    "010201010"  101020101003 1  3  .  1  8
    "010201010"  101020101005 1  5  .  1  7
    "010201010"  101020101006 1  6  .  1  2
    "010201020"  101020102001 1  1  2  . 10
    "0102010201" 101020102001 2  1 75 75 12
    "010201020"  101020102003 1  3  4  1 15
    "0102010201" 101020102003 2  3  3  1 15
    "010201020"  101020102004 1  4  3  .  0
    "0102010201" 101020102004 2  4  2  .  8
    "010201020"  101020102005 1  5  .  3  7
    "0102010201" 101020102005 2  5  .  2 12
    "010201020"  101020102006 1  6  .  3  3
    "0102010201" 101020102006 2  6  .  2  8
    "010201020"  101020102007 1  7  .  3  0
    "0102010201" 101020102007 2  7  .  2  5
    "010201020"  101020102008 1  8  9  1 15
    "0102010201" 101020102008 2  8  8  1 15
    "010201020"  101020102009 1  9  8  . 12
    "0102010201" 101020102009 2  9  7  . 12
    "010201020"  101020102010 1 10  .  8  2
    "0102010201" 101020102010 2 10  .  7  6
    "010201020"  101020102011 1 11  .  8  0
    "0102010201" 101020102011 2 11  .  7  2
    "010201020"  101020102012 1 12 13  1 15
    "0102010201" 101020102012 2 12 13  1 15
    "010201020"  101020102013 1 13 12  . 12
    "0102010201" 101020102013 2 13 12  .  7
    "010201020"  101020102014 1 14  . 12  0
    "0102010201" 101020102014 2 14  . 12  0
    "010201020"  101020102015 1 15  .  .  0
    "0102010201" 101020102015 2 15  .  .  0
    "010201030"  101020103001 1  1  2  .  9
    "0102010301" 101020103001 2  1  2 69 10
    "010201030"  101020103002 1  2  1  .  0
    "0102010301" 101020103002 2  2  1  .  0
    "010201030"  101020103003 1  3  .  1  9
    "0102010301" 101020103003 2  3  .  1 11
    "010201030"  101020103004 1  4  .  1  6
    "0102010301" 101020103004 2  4  .  1 12
    "010201030"  101020103005 1  5  .  1  5
    "0102010301" 101020103005 2  5  .  1  9
    "010201030"  101020103006 1  6  .  1  1
    "0102010301" 101020103006 2  6  .  1  6
    "010201030"  101020103007 1  7  .  1  0
    "0102010301" 101020103007 2  7  .  1  4
    "010201040"  101020104001 1  1  2  .  0
    "0102010401" 101020104001 2  1  2 75  0
    "010201040"  101020104002 1  2  1  .  0
    "0102010401" 101020104002 2  2  1  .  0
    "010201040"  101020104003 1  3  .  1  6
    "0102010401" 101020104003 2  3  .  1  5
    "010201040"  101020104004 1  4  .  1  1
    "0102010401" 101020104004 2  4  .  1  7
    "010201040"  101020104005 1  5  .  1  0
    "0102010401" 101020104005 2  5  .  1  6
    "010201050"  101020105002 1  2  3  1  0
    "0102010501" 101020105002 2  2  2 75  8
    "010201050"  101020105003 1  3  2  .  0
    "0102010501" 101020105003 2  3  1  .  0
    "010201050"  101020105006 1  6  .  2  0
    "0102010501" 101020105006 2  6  4  1  0
    "010201050"  101020105007 1  7  .  2  8
    "0102010501" 101020105007 2  7  7  1  9
    "010201050"  101020105008 1  8  .  2  5
    "0102010501" 101020105008 2  8  .  1 12
    "010201050"  101020105009 1  9  .  2  4
    "0102010501" 101020105009 2  9  .  1  9
    "010201050"  101020105010 1 10  .  2  0
    "0102010501" 101020105010 2 10  .  1  4
    "010201060"  101020106001 1  1 75  .  0
    "0102010601" 101020106001 2  1 75 75  0
    "010201060"  101020106012 1 12  .  1  0
    "0102010601" 101020106012 2 12  3  1  0
    "010201060"  101020106013 1 13 14  1  0
    "0102010601" 101020106013 2 13  7  1  0
    "010201060"  101020106014 1 14 13  .  0
    "0102010601" 101020106014 2 14  6  .  0
    "010201060"  101020106015 1 15  .  1  0
    "0102010601" 101020106015 2 15 11  1  0
    "010201070"  101020107001 1  1  2  .  0
    "0102010701" 101020107001 2  1  2 75  0
    "010201070"  101020107002 1  2  1  .  0
    "0102010701" 101020107002 2  2  1  .  0
    "010201070"  101020107003 1  3  .  1  0
    "0102010701" 101020107003 2  3  .  1  0
    "010201070"  101020107004 1  4  .  1  7
    "0102010701" 101020107004 2  4  .  1  8
    "010201070"  101020107006 1  6  .  1  0
    "0102010701" 101020107006 2  6  .  1  0
    "010201070"  101020107007 1  7  .  1  0
    "0102010701" 101020107007 2  7  .  1  0
    "010201070"  101020107008 1  8  .  1  1
    "0102010701" 101020107008 2  8  .  1  9
    "010201070"  101020107009 1  9  .  1  1
    "0102010701" 101020107009 2  9  .  1  9
    "010201080"  101020108001 1  1  2  .  0
    "0102010801" 101020108001 2  1  2  .  0
    "010201080"  101020108002 1  2  1  .  0
    end
    label values SURVEY SURVEY
    label def SURVEY 1 "IHDS1 1", modify
    label def SURVEY 2 "IHDS2 2", modify
    label values RO8 RO8
    label def RO8 75 "Died 75", modify
    label values RO9 RO9
    label def RO9 69 "Other nonres 69", modify
    label def RO9 75 "Died 75", modify
    label values ED6 ED6
    label def ED6 0 "none, <1 0", modify
    label def ED6 1 "1st class 1", modify
    label def ED6 2 "2nd class 2", modify
    label def ED6 3 "3rd class 3", modify
    label def ED6 4 "4th class 4", modify
    label def ED6 5 "5th class 5", modify
    label def ED6 6 "6th class 6", modify
    label def ED6 7 "7th class 7", modify
    label def ED6 8 "8th class 8", modify
    label def ED6 9 "9th class 9", modify
    label def ED6 10 "Secondary 10", modify
    label def ED6 11 "11th Class 11", modify
    label def ED6 12 "High Secondary 12", modify
    label def ED6 15 "Bachelors 15", modify
    
    format HHPBASE %12.0f
    
    rename RO8 father_id
    rename RO9 mother_id
    
    isid IDHH PBASE SURVEY
    
    frame copy default second
    frlink m:1 IDHH father_id SURVEY, frame(second IDHH PBASE SURVEY) gen(flink)
    frlink m:1 IDHH mother_id SURVEY, frame(second IDHH PBASE SURVEY) gen(mlink)
    
    gen father_educ = frval(flink, ED6)
    gen mother_educ = frval(mlink, ED6)
    label values father_educ mother_educ ED6
    Note: The renaming of those variables is not necessary: you remove the -rename- commands and replace the references to father_id, and mother_id by their original names in the rest of the code. I just do it because I find it very difficult to work with variable names like that and keep straight which is which. Since there is a fair amount of action going on here that requires keeping mother and father straight, I find it better to use variable names that state which is which. But you don't have to do that if you don't want to.
    Last edited by Clyde Schechter; 30 Mar 2020, 19:41.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Well, either I'm misunderstanding your explanation of the data or there is something seriously wrong with your data. Let's look at IDHH 010201010 in round 1. PBASE 1 has PBASE 2 as his father, but PBASE 2 has PBASE 1 as his father. So PBASE 1 and PBASE 2 are each the father of the other. That can't possibly be right.

      Also your variables R08 and R09 also contain special values referring to things like "Died 75" and "Other nonres 69." That is one of the most bizarre conflations of unrelated information in the same variable I have ever seen and I cannot believe you will get through much analysis of this data without all sorts of strange errors cropping up as a result of that. I strongly recommend replacing those by missing values and, if the information about Died 75 or Other nonres 69 is important, create new variables to indicate those conditions.

      Anyway, assuming that the data are messed up and that your description of it is correct, the following code, when supplied with correct data, would work
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear*
      input str10 IDHH double HHPBASE int(SURVEY PBASE RO8 RO9 ED6)
      "010201010" 101020101001 1 1 2 . 0
      "010201010" 101020101002 1 2 1 . 0
      "010201010" 101020101003 1 3 . 1 8
      "010201010" 101020101005 1 5 . 1 7
      "010201010" 101020101006 1 6 . 1 2
      "010201020" 101020102001 1 1 2 . 10
      "0102010201" 101020102001 2 1 75 75 12
      "010201020" 101020102003 1 3 4 1 15
      "0102010201" 101020102003 2 3 3 1 15
      "010201020" 101020102004 1 4 3 . 0
      "0102010201" 101020102004 2 4 2 . 8
      "010201020" 101020102005 1 5 . 3 7
      "0102010201" 101020102005 2 5 . 2 12
      "010201020" 101020102006 1 6 . 3 3
      "0102010201" 101020102006 2 6 . 2 8
      "010201020" 101020102007 1 7 . 3 0
      "0102010201" 101020102007 2 7 . 2 5
      "010201020" 101020102008 1 8 9 1 15
      "0102010201" 101020102008 2 8 8 1 15
      "010201020" 101020102009 1 9 8 . 12
      "0102010201" 101020102009 2 9 7 . 12
      "010201020" 101020102010 1 10 . 8 2
      "0102010201" 101020102010 2 10 . 7 6
      "010201020" 101020102011 1 11 . 8 0
      "0102010201" 101020102011 2 11 . 7 2
      "010201020" 101020102012 1 12 13 1 15
      "0102010201" 101020102012 2 12 13 1 15
      "010201020" 101020102013 1 13 12 . 12
      "0102010201" 101020102013 2 13 12 . 7
      "010201020" 101020102014 1 14 . 12 0
      "0102010201" 101020102014 2 14 . 12 0
      "010201020" 101020102015 1 15 . . 0
      "0102010201" 101020102015 2 15 . . 0
      "010201030" 101020103001 1 1 2 . 9
      "0102010301" 101020103001 2 1 2 69 10
      "010201030" 101020103002 1 2 1 . 0
      "0102010301" 101020103002 2 2 1 . 0
      "010201030" 101020103003 1 3 . 1 9
      "0102010301" 101020103003 2 3 . 1 11
      "010201030" 101020103004 1 4 . 1 6
      "0102010301" 101020103004 2 4 . 1 12
      "010201030" 101020103005 1 5 . 1 5
      "0102010301" 101020103005 2 5 . 1 9
      "010201030" 101020103006 1 6 . 1 1
      "0102010301" 101020103006 2 6 . 1 6
      "010201030" 101020103007 1 7 . 1 0
      "0102010301" 101020103007 2 7 . 1 4
      "010201040" 101020104001 1 1 2 . 0
      "0102010401" 101020104001 2 1 2 75 0
      "010201040" 101020104002 1 2 1 . 0
      "0102010401" 101020104002 2 2 1 . 0
      "010201040" 101020104003 1 3 . 1 6
      "0102010401" 101020104003 2 3 . 1 5
      "010201040" 101020104004 1 4 . 1 1
      "0102010401" 101020104004 2 4 . 1 7
      "010201040" 101020104005 1 5 . 1 0
      "0102010401" 101020104005 2 5 . 1 6
      "010201050" 101020105002 1 2 3 1 0
      "0102010501" 101020105002 2 2 2 75 8
      "010201050" 101020105003 1 3 2 . 0
      "0102010501" 101020105003 2 3 1 . 0
      "010201050" 101020105006 1 6 . 2 0
      "0102010501" 101020105006 2 6 4 1 0
      "010201050" 101020105007 1 7 . 2 8
      "0102010501" 101020105007 2 7 7 1 9
      "010201050" 101020105008 1 8 . 2 5
      "0102010501" 101020105008 2 8 . 1 12
      "010201050" 101020105009 1 9 . 2 4
      "0102010501" 101020105009 2 9 . 1 9
      "010201050" 101020105010 1 10 . 2 0
      "0102010501" 101020105010 2 10 . 1 4
      "010201060" 101020106001 1 1 75 . 0
      "0102010601" 101020106001 2 1 75 75 0
      "010201060" 101020106012 1 12 . 1 0
      "0102010601" 101020106012 2 12 3 1 0
      "010201060" 101020106013 1 13 14 1 0
      "0102010601" 101020106013 2 13 7 1 0
      "010201060" 101020106014 1 14 13 . 0
      "0102010601" 101020106014 2 14 6 . 0
      "010201060" 101020106015 1 15 . 1 0
      "0102010601" 101020106015 2 15 11 1 0
      "010201070" 101020107001 1 1 2 . 0
      "0102010701" 101020107001 2 1 2 75 0
      "010201070" 101020107002 1 2 1 . 0
      "0102010701" 101020107002 2 2 1 . 0
      "010201070" 101020107003 1 3 . 1 0
      "0102010701" 101020107003 2 3 . 1 0
      "010201070" 101020107004 1 4 . 1 7
      "0102010701" 101020107004 2 4 . 1 8
      "010201070" 101020107006 1 6 . 1 0
      "0102010701" 101020107006 2 6 . 1 0
      "010201070" 101020107007 1 7 . 1 0
      "0102010701" 101020107007 2 7 . 1 0
      "010201070" 101020107008 1 8 . 1 1
      "0102010701" 101020107008 2 8 . 1 9
      "010201070" 101020107009 1 9 . 1 1
      "0102010701" 101020107009 2 9 . 1 9
      "010201080" 101020108001 1 1 2 . 0
      "0102010801" 101020108001 2 1 2 . 0
      "010201080" 101020108002 1 2 1 . 0
      end
      label values SURVEY SURVEY
      label def SURVEY 1 "IHDS1 1", modify
      label def SURVEY 2 "IHDS2 2", modify
      label values RO8 RO8
      label def RO8 75 "Died 75", modify
      label values RO9 RO9
      label def RO9 69 "Other nonres 69", modify
      label def RO9 75 "Died 75", modify
      label values ED6 ED6
      label def ED6 0 "none, <1 0", modify
      label def ED6 1 "1st class 1", modify
      label def ED6 2 "2nd class 2", modify
      label def ED6 3 "3rd class 3", modify
      label def ED6 4 "4th class 4", modify
      label def ED6 5 "5th class 5", modify
      label def ED6 6 "6th class 6", modify
      label def ED6 7 "7th class 7", modify
      label def ED6 8 "8th class 8", modify
      label def ED6 9 "9th class 9", modify
      label def ED6 10 "Secondary 10", modify
      label def ED6 11 "11th Class 11", modify
      label def ED6 12 "High Secondary 12", modify
      label def ED6 15 "Bachelors 15", modify
      
      format HHPBASE %12.0f
      
      rename RO8 father_id
      rename RO9 mother_id
      
      isid IDHH PBASE SURVEY
      
      frame copy default second
      frlink m:1 IDHH father_id SURVEY, frame(second IDHH PBASE SURVEY) gen(flink)
      frlink m:1 IDHH mother_id SURVEY, frame(second IDHH PBASE SURVEY) gen(mlink)
      
      gen father_educ = frval(flink, ED6)
      gen mother_educ = frval(mlink, ED6)
      label values father_educ mother_educ ED6
      Note: The renaming of those variables is not necessary: you remove the -rename- commands and replace the references to father_id, and mother_id by their original names in the rest of the code. I just do it because I find it very difficult to work with variable names like that and keep straight which is which. Since there is a fair amount of action going on here that requires keeping mother and father straight, I find it better to use variable names that state which is which. But you don't have to do that if you don't want to.
      Hi Clyde,

      Thank you so much for this, it worked perfectly. I did not know of frames and it has been very helpful.

      I just wanted to clarify that I got the labels a little mixed up, RO8 actually refers to the spouse, hence why two people would have each other marked as spouse, my bad completely. Have definitely renamed my variables to use as I go forward!

      Kind regards,
      Sanchit

      Comment


      • #4
        Dear Prof. Clyde,

        I am using Stata version 14.2, so I am unable to use frame command/function. Could you please rewrite the code in #2 using merge command? Thank you.

        Comment


        • #5
          Code:
          rename RO8 father_id
          rename RO9 mother_id
          
          isid IDHH PBASE SURVEY
          
          clonevar link = PBASE
          clonevar parent_educ = ED6
          tempfile second
          save `second'
          drop link parent_educ
          
          clonevar link = father_id
          merge m:1 IDHH link SURVEY using `second', keepusing(parent_educ) ///
              keep(master match) nogenerate
          rename parent_educ father_educ
          sort IDHH PBASE SURVEY
          
          drop link
          clonevar link = mother_id
          merge m:1 IDHH link SURVEY using `second', keepusing(parent_educ) ///
              keep(master match) nogenerate
          rename parent_educ mother_educ
          
          label values father_educ mother_educ ED6

          Comment


          • #6
            Thank you so much for your kind help, Prof. Clyde.

            Comment

            Working...
            X