Dear Stata users, I have the following data sample where fam_id represents the family, hh_count represents the number of family members within a family. Mother, father, and person_id are the string variables that identify the person and other family members. In the last column, I find the location of the mother of the corresponding family member.
clear
input byte fam_id str1(mother father person_id) byte(hh_count place_mother)
1 "" "" "x" 1 .
1 "x" "y" "d" 2 1
1 "x" "y" "e" 3 1
1 "x" "y" "f" 4 1
1 "z" "b" "y" 5 6
1 "a" "c" "z" 6 .
end
For example, the person e's mother is x and located at the 1st column of person_id.
I want to create a new variable that identifies the mother. What I require is something like this:
input byte fam_id str1(mother father person_id) byte(hh_count place_mother) float mother_find
1 "" "" "x" 1 . 1
1 "x" "y" "d" 2 1 .
1 "x" "y" "e" 3 1 .
1 "x" "y" "f" 4 1 .
1 "z" "b" "y" 5 6 .
1 "a" "c" "z" 6 . 2
end
Could you please help me with that?
Regards,
Related Posts with Identify the variable based on a given location
Destringing and Dropping.Hello, How would I go about telling stata to drop the observations of variable nace_r2, when the fi…
Lag in Regression with Newey–West standard errorsPlease help resolve some confusion regarding newey (the command to run NW SE regression in Stata): …
Intersection of two matricesThis feels like a super basic question, but how do I find the intersection of two matrices in mata? …
Regression Discontinuity - RDDensity test (Cattaneo)Hello everyone, This is my first time using Statalist as well as first time trying to do anything w…
Drop observation if missing in two discontinous yearsHello, I have a lot of balance sheet data (with a lot of variables). What I need is for every idnr …
Subscribe to:
Post Comments (Atom)
0 Response to Identify the variable based on a given location
Post a Comment