Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_father_variables
args father_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep idperson `father_vars'
rename idperson idfather

tokenize `father_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' father_`1'
}
macro shift //process each token in a loop
}
sort idfather

save "${local_data}/temp_father", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort idfather
merge m:1 idfather using "${local_data}/temp_father" // Merge the temporary dataset to original , m:1 because idfather can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_father_variables2
args father_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep stm idperson `father_vars'
rename idperson idfather

tokenize `father_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' father_`1'
}
macro shift //process each token in a loop
}
sort stm idfather

save "${local_data}/temp_father", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort stm idfather
merge m:1 stm idfather using "${local_data}/temp_father" // Merge the temporary dataset to original , m:1 because idfather can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_mother_variables
args mother_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep idperson `mother_vars'
rename idperson idmother

tokenize `mother_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' mother_`1'
}
macro shift //process each token in a loop
}
sort idmother

save "${local_data}/temp_mother", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort idmother
merge m:1 idmother using "${local_data}/temp_mother" // Merge the temporary dataset to original , m:1 because idmother can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_mother_variables2
args mother_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep stm idperson `mother_vars'
rename idperson idmother

tokenize `mother_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' mother_`1'
}
macro shift //process each token in a loop
}
sort stm idmother

save "${local_data}/temp_mother", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort stm idmother
merge m:1 stm idmother using "${local_data}/temp_mother" // Merge the temporary dataset to original , m:1 because idmother can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_partner_variables
args partner_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep idperson `partner_vars'
rename idperson idpartner

tokenize `partner_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' partner_`1'
}
macro shift //process each token in a loop
}
sort idpartner
//sum partner_*
save "${local_data}/temp_partner", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort idpartner
merge m:1 idpartner using "${local_data}/temp_partner" // Merge the temporary dataset to original , m:1 because idpartner can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROGRAM TO ATTACH PARTNER VARIABLES TO THE RESPONDENT //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program define add_partner_variables2
args partner_vars //assign arguments to local macros

preserve // Preserve the original dataset
keep stm idperson `partner_vars'
rename idperson idpartner

tokenize `partner_vars' // Split partner_vars into a list and store each resulting token in a numbered local macro.
while "`1'" != "" { // Loop over each variable and rename
capture confirm variable `1' // Check if the variable exists in the dataset
if !_rc {
rename `1' partner_`1'
}
macro shift //process each token in a loop
}
sort stm idpartner
//sum partner_*
save "${local_data}/temp_partner", replace // Save the modified dataset to a temporary file
restore // Restore the original dataset

sort stm idpartner
merge m:1 stm idpartner using "${local_data}/temp_partner" // Merge the temporary dataset to original , m:1 because idpartner can be zero for many
keep if _merge == 1 | _merge == 3
drop _merge
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Loading
Loading