Dear Statalist,
Please consider this simplified dataset:
This dataset represents a family of 3 individuals observed twice, in 2006 for the variables ending with _2006 and in 2020 for the variables ending with _2020. There is a unique, longitudinal individual identifier called "id_panel" allowing to follow an individual over time. However, as household composition can vary over time, it's impossible to have a unique, longitudinal, household id.
In this datasets, the first observation, a child, leaves the family between 2006 and 2020. It is missing in 2020, but one can know that the child left thanks to the variable ybirth_CA_2020. CA means "Child Away".
My purpose is to create a binary variable called "departure_from_home_2020" equal to 1 if, in the previous wave of the survey, here 2006, there was a child within the household of individual, but not anymore in 2020.
The hard task here is the fluctuating household ID over time, represented by AAA and BBB for the same individuals. One condition of the variable is that the ybirth_2006 and ybirth_CA_2020 are the same. Can anyone help me achieve this purpose? I would appreciate any help!
Please consider this simplified dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str2 id_panel str20 status_2020 float ybirth_2020 str3 hhid_2020 int ybirth_CA_2020 str20 status_2006 float ybirth_2006 str3 hhid_2006 float ybirth_CA_2006 "1" "" . "" . "child" 1999 "BBB" . "2" "respondent" 1964 "AAA" 1999 "respondent" 1964 "BBB" . "3" "respondent's partner" 1970 "AAA" 1999 "respondent's partner" 1970 "BBB" . end
This dataset represents a family of 3 individuals observed twice, in 2006 for the variables ending with _2006 and in 2020 for the variables ending with _2020. There is a unique, longitudinal individual identifier called "id_panel" allowing to follow an individual over time. However, as household composition can vary over time, it's impossible to have a unique, longitudinal, household id.
In this datasets, the first observation, a child, leaves the family between 2006 and 2020. It is missing in 2020, but one can know that the child left thanks to the variable ybirth_CA_2020. CA means "Child Away".
My purpose is to create a binary variable called "departure_from_home_2020" equal to 1 if, in the previous wave of the survey, here 2006, there was a child within the household of individual, but not anymore in 2020.
The hard task here is the fluctuating household ID over time, represented by AAA and BBB for the same individuals. One condition of the variable is that the ybirth_2006 and ybirth_CA_2020 are the same. Can anyone help me achieve this purpose? I would appreciate any help!
Comment