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
AsdocHi, I am using asdoc to produce some mean difference tests (ttest). How can I change the names of t…
Matrix of sums of submatricesI have matrix A. I'd like to create a new matrix B where each element is the sum of a corresponding …
How can I install meta analysis package in my stata 17?Dear, professor, I want to install a meta-analysis package on my Stata 17. It shows like that. Runni…
How to Use Stata Code to Count How Many Students ever took More Than 1 Time Exam?I have a small dataset and it just has 2 variables. ID---student ID, exam_times----how many times a …
syntax: add a minus before a list of variablesDear Stata users, I want to make a convenient wrapper using gsort command. My question is how to ad…
Subscribe to:
Post Comments (Atom)
0 Response to Identify the variable based on a given location
Post a Comment