The data set as imported is a bit messy. You have several variables that appear to be numeric in content but came in as strings. Based on the table you showed in #1, I have transformed those into value-labeled numeric variables. For labor status there was no crosswalk, so I have just left the string-numbers as is, but you should deal with this yourself. Categorical variables are usually easier to work with as value-labeled numeric variables than as strings. And strings like "1" etc. are particularly awkward.
I still don't understand quite what comparisons you are trying to make, though at the very end of the code shown below I have given you an example of what I might do with this data that is along the lines of what you ask for as best I understand it. The bulk of the code, apart from data cleaning, involves associating parental data to the children. At the end you have a data set of all the children, with their father's and mother's attributes in their observations as well. I imagine you can take it from there.
I still don't understand quite what comparisons you are trying to make, though at the very end of the code shown below I have given you an example of what I might do with this data that is along the lines of what you ask for as best I understand it. The bulk of the code, apart from data cleaning, involves associating parental data to the children. At the end you have a data set of all the children, with their father's and mother's attributes in their observations as well. I imagine you can take it from there.
Code:
destring sex, replace label define sex 1 "Male" 2 "Female" label values sex sex destring educationalqualification, replace label define educationalqualification 1 "Basic Qualification" /// 2 "Second Level" /// 3 "No Qualification" label values educationalqualification educationalqualification destring currentlyenrolledinschl, replace label define yesno 0 "No" 1 "Yes" label values currentlyenrolledinschl yesno destring relationship, replace label define relationship 1 "Head" /// 2 "Spouse" /// 3 "Child" /// 4 "Grandchild" destring maritalstatus, replace label define maritalstatus 1 "Married" /// 2 "???" /// 3 "Divorced" /// 4 "Widowed" /// 5 "Never Married" label values maritalstatus maritalstatus frame put hhnsrrno sex maritalstatus educationalqualification b5labour /// if inlist(relationship, 1, 2), into(parents) frame parents { by hhnsrrno (sex), sort: assert _N <= 2 // VERIFY AT MOST HEAD AND SPOUSE gen suffix = cond(sex == 1, "_father", "_mother") drop sex reshape wide maritalstatus educationalqualification b5labour, /// i(hhnsrrno) j(suffix) string } keep if relationship == 3 & inrange(age, 4, 28) frlink m:1 hhnsrrno, frame(parents) frget _all, from(parents) tab educationalqualification_father currentlyenrolledinschl, col
Comment