Hello Statalisters,

I would like to generate for each spouse (female) in each household id (Fhhid), a mother in law education and the mother in law sector of employment from the mother of her husband (Head of household) variables.

I have the relation to household (reltohd) variable that indicates 1 for head and 2 for spouse.

Could you please explain to me how I can possibly generate these variables?

Thank you in advance

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str21 Fhhid str23 Findid byte(reltohd mtocp1d mtsectr mteducst)
"18122401052"      "1812240105203"       2 . . 1
"18121903601_1803" "18121903601_180301"  . . . .
"06298331"         "0629833101"          3 . . 1
"122800721"        "12280072102"         . . . .
"06267472"         "0626747202"          . . . .
"98130006"         "9813000604"          1 . . 1
"98130084"         "9813008402"          . . . .
"06215542"         "0621554203"          1 . . 1
"06195330"         "0619533003"          2 . . 1
"98260123"         "9826012302"          . . . .
"122204891"        "12220489102"         3 . . 1
"181802521090012"  "18180252109001206"   . . . .
"98240058"         "9824005803"          . . . .
"98240201"         "9824020101"          . . . .
"18122401191_1804" "18122401191_180401"  . . . .
"18122602692"      "1812260269202"       3 . . .
"98160051"         "9816005101"          1 . . 2
"98180242"         "9818024205"          3 . . .
"98140201"         "9814020101"          . . . .
"18121803731_1804" "18121803731_180402"  2 . . 1
"181802520330011"  "18180252033001104"   . . . .
"18122303331_1804" "18122303331_180402"  . . . .
"18122504372_1803" "18122504372_180303"  . . . .
"18122704402"      "1812270440207"       . . . .
"98210136"         "9821013602"          . . . .
"98010846"         "9801084601"          . . . .
"181801920060002"  "18180192006000204"   . . . .
"98010049"         "9801004902"         10 . . 1
"98230042"         "9823004202"          . . . .
"98220300"         "9822030004"          5 . . 1
"98011255"         "9801125503"          3 . . 1
"98270175"         "9827017501"          1 . . 1
"06184795"         "0618479507"          1 . . 1
"98130295"         "9813029506"          . . . .
"18122401271_1804" "18122401271_180402"  2 . . 1
"18122605252"      "1812260525208"       . . . .
"98270053"         "9827005317"          . . . .
"98160162"         "9816016201"          1 . . 2
"98120137"         "9812013703"          . . . .
"98130170"         "9813017001"          . . . .
"18122401351"      "1812240135106"       . . . .
"181801310750001"  "18180131075000101"   . . . .
"120203811"        "12020381106"         . . . .
"181802620700008"  "18180262070000805"   . . . .
"98010984"         "9801098404"          . . . .
"98260221"         "9826022101"          . . . .
"06185021"         "0618502102"          . . . .
"98020577"         "9802057705"          . . . .
"98210402"         "9821040205"          . . . .
"18121701402"      "1812170140204"       . . . .
"98140290"         "9814029002"          . . . .
"18122401431"      "1812240143104"       1 . . 1
"98160017"         "9816001703"          . . . .
"06011087"         "0601108701"          1 . . 1
"98130386"         "9813038602"          2 . . 1
"98120097"         "9812009704"          . . . .
"181802720980005"  "18180272098000502"   . . . .
"18122401491"      "1812240149104"       3 . . 1
"181801210870003"  "18180121087000301"   3 . . .
"98170201"         "9817020101"          . . . .
"98010338"         "9801033801"          . . . .
"18122401501"      "1812240150105"       . . . .
"122106231"        "12210623102"         3 6 3 1
"98260058"         "9826005807"          . . . .
"18121904942"      "1812190494204"       2 . . 1
"98230131"         "9823013103"          . . . .
"98160161"         "9816016101"          . . . .
"98160161"         "9816016101"          1 . . 1
"121504522"        "12150452203"         . . . .
"18122401532_1804" "18122401532_180404"  2 . . 1
"18122801241_1805" "18122801241_180501"  3 . . .
"18122102902"      "1812210290205"       . . . .
"18122302161"      "1812230216106"       . . . .
"98210447"         "9821044703"          3 . . 4
"122106112"        "12210611203"         . . . .
"98160142"         "9816014203"          . . . .
"122104772"        "12210477203"         2 6 3 1
"98020743"         "9802074302"          . . . .
"121303221"        "12130322107"         1 6 3 1
"18122709062"      "1812270906204"       . . . .
"98150286"         "9815028602"          . . . .
"98260012"         "9826001205"          3 2 1 6
"18122505582_1805" "18122505582_180503"  . . . .
"122304222"        "12230422205"         . . . .
"18122404192"      "1812240419222"       . . . .
"18122401572"      "1812240157205"       . . . .
"98250261"         "9825026101"          . . . .
"98130100"         "9813010003"          . . . .
"98130096"         "9813009604"          . . . .
"18122401582"      "1812240158205"       . . . .
"98180050"         "9818005006"          . . . .
"18122488882"      "1812248888205"       . . . .
"181802720890010"  "18180272089001003"   . . . .
"18122605002_1803" "18122605002_180303"  . . . .
"122402101"        "12240210104"         . . . .
"06236447"         "0623644702"          . . . .
"06256954"         "0625695407"          . . . .
"98220056"         "9822005605"          3 . . 1
"122204062"        "12220406205"         . . . .
"98010247"         "9801024701"          . . . .
end