Dear Statalist,

I am trying to match couples (married or cohab) in a pooled cross section. I have a household ID (hhid) for every quarter that appears only unique to a particular quarter. To keep things simpler at the start, I look only at wave 1 of every year (Q1). At the end of the day, I want to run a reduced form labor supply equation for women only with the spouse's years in the yuk (spyuk) and the woman's years in the UK (yuk) including a bunch of controls where yuk==0 and spyuk==0 for natives, so something like this:
Code:
regress jobhrs yuk spyuk
In the sample dataset, I have defined yuk and spyuk identically, so they are the same values in each given row. Again, the native couples have all zeros for yuk and spyuk. For instance, a given wife (a given row) has for her own yuk a zero entry and for her partner a zero entry since I defined the variables in the same way. The magic now is to replace the spyuk in the row for the women with the correct spyuk of her partner (mostly men) in the row below or above.
If anyone happens to have a complete different idea as to how to match couples (I got hhid, wave, surveyyear) in a rough manner differently from what I am suggesting, I am open to any suggestions.

Thank you very much.

Nico



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str13 hhid int year byte wave float(yuk spyuk jobhrs) byte(relhfu familytype) float im
"            1" 2011 1  0  0 60 1 4 0
"            1" 2011 1  0  0 37 2 4 0
"            1" 2014 1  0  0 40 1 9 0
"            1" 2014 1  0  0 36 2 9 0
"            2" 2011 1  6  6 30 2 7 1
"            2" 2011 1  0  0 38 1 7 0
"            2" 2015 1  0  0 24 2 4 0
"            2" 2015 1  0  0 45 1 4 0
"            2" 2017 1 13 13 45 1 9 1
"            2" 2017 1  0  0 16 2 9 0
"            3" 2013 1  0  0  4 2 7 0
"            3" 2014 1  0  0 38 1 6 0
"            3" 2014 1  0  0 13 2 6 0
"            3" 2017 1  0  0 45 1 4 0
"            4" 2013 1  0  0 60 1 6 0
"            4" 2015 1  0  0 36 1 9 0
end
label values year REFWKY
label values wave THISWV
label values relhfu RELHFU
label def RELHFU 1 "Head of family unit", modify
label def RELHFU 2 "Wife or partner of head", modify
label values familytype FUTYPE6
label def FUTYPE6 4 "Married couple with no children", modify
label def FUTYPE6 6 "Married couple with dep children", modify
label def FUTYPE6 7 "Cohab couple with no children", modify
label def FUTYPE6 9 "Cohab couple with dep children", modify