Hello,
I want to link parents and their children by putting the proper value (id) in variables (father, mother, children1, ....).
Would you help me to do that? Thanks.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long pid int hhid byte(hmem female age) float(relation father mother children1 children2 children3)
 101  1 1 1 57 1 . . . . .
 102  1 2 0 30 2 . . . . .
 201  2 1 0 47 1 . . . . .
 202  2 2 1 44 3 . . . . .
 203  2 3 1 19 2 . . . . .
 301  3 1 1 36 1 . . . . .
 401  4 1 0 28 1 . . . . .
 402  4 2 1 29 3 . . . . .
 501  5 1 1 24 1 . . . . .
 601  6 1 0 72 1 . . . . .
 602  6 2 1 63 3 . . . . .
 603  6 3 1 31 2 . . . . .
 604  6 4 0 27 2 . . . . .
 701  7 1 1 74 1 . . . . .
 801  8 1 0 26 1 . . . . .
 901  9 1 1 80 1 . . . . .
 902  9 2 1 28 2 . . . . .
 903  9 3 1 26 2 . . . . .
1001 10 1 1 44 1 . . . . .
1101 11 1 0 41 1 . . . . .
1102 11 2 1 49 3 . . . . .
1201 12 1 1 22 1 . . . . .
1301 13 1 0 56 1 . . . . .
1302 13 2 1 49 3 . . . . .
1303 13 3 1 25 2 . . . . .
end
label values female female
label def female 0 "male", modify
label def female 1 "female", modify
label values relation h_relation
label def h_relation 1 "head", modify
label def h_relation 2 "child", modify
label def h_relation 3 "spouse", modify