Dear all,
I have the following variables indicating whether in a household (identified by hhid) the person refers to a mother and a father (a couple) and a son/daughter and their respective partner (son/daughter in law):
I want to create a couple_id based on this information such that each mother and father in a household form a couple and each son and daughter in law another couple and daughter and son in law another couple and do this for every household such that my couple_id identifies essentially all the couples I have.
An example of the data is as follows:
clear
input str9 pidlink long hhid float(mother_id father_id son_id daughter_id son_inlaw_id daughter_inlaw_id)
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020004" 1000200 . . 1 . . .
"100020005" 1000200 . . . 1 . .
"100020007" 1000200 . . . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030005" 1000300 . . . . . .
"100030006" 1000300 . . . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100043101" 1000431 . 1 . . . .
"100043103" 1000431 . . . 1 . .
"100043104" 1000431 . . 1 . . .
"100043105" 1000431 . . . . . .
"100043106" 1000431 . . . . . .
"100044101" 1000441 . 1 . . . .
"100044103" 1000400 . . . . . .
"100050001" 1000500 . 1 . . . .
"100050001" 1000500 . 1 . . . .
"100050001" 1000500 . 1 . . . .
"100050002" 1000500 1 . . . . .
"100050002" 1000500 1 . . . . .
"100050002" 1000500 1 . . . . .
"100060001" 1000600 . 1 . . . .
"100060001" 1000600 . 1 . . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060003" 1000600 . . . . . 1
"100060003" 1000600 . . . . . 1
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
Any help would be appreciated
I have the following variables indicating whether in a household (identified by hhid) the person refers to a mother and a father (a couple) and a son/daughter and their respective partner (son/daughter in law):
I want to create a couple_id based on this information such that each mother and father in a household form a couple and each son and daughter in law another couple and daughter and son in law another couple and do this for every household such that my couple_id identifies essentially all the couples I have.
An example of the data is as follows:
clear
input str9 pidlink long hhid float(mother_id father_id son_id daughter_id son_inlaw_id daughter_inlaw_id)
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010001" 1000100 . 1 . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010002" 1000100 1 . . . . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010003" 1000100 . . . 1 . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100010004" 1000100 . . . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020001" 1000200 . 1 . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020002" 1000200 1 . . . . .
"100020004" 1000200 . . 1 . . .
"100020005" 1000200 . . . 1 . .
"100020007" 1000200 . . . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030001" 1000300 . 1 . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030002" 1000300 1 . . . . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030003" 1000300 . . . 1 . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030004" 1000300 . . . . . .
"100030005" 1000300 . . . . . .
"100030006" 1000300 . . . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040001" 1000400 . 1 . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040002" 1000400 1 . . . . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040003" 1000400 . . . 1 . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040004" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040005" 1000400 . . . . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100040006" 1000400 . . 1 . . .
"100043101" 1000431 . 1 . . . .
"100043103" 1000431 . . . 1 . .
"100043104" 1000431 . . 1 . . .
"100043105" 1000431 . . . . . .
"100043106" 1000431 . . . . . .
"100044101" 1000441 . 1 . . . .
"100044103" 1000400 . . . . . .
"100050001" 1000500 . 1 . . . .
"100050001" 1000500 . 1 . . . .
"100050001" 1000500 . 1 . . . .
"100050002" 1000500 1 . . . . .
"100050002" 1000500 1 . . . . .
"100050002" 1000500 1 . . . . .
"100060001" 1000600 . 1 . . . .
"100060001" 1000600 . 1 . . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060002" 1000600 . . 1 . . .
"100060003" 1000600 . . . . . 1
"100060003" 1000600 . . . . . 1
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060004" 1000600 . . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
"100060005" 1000600 1 . . . . .
Any help would be appreciated
Comment