Hi Statalist.

I have created a categorical variable that represents the marital status of all couples in my panel data set. I create three separate categories (1) always de facto (2) de facto, then married (3) always married. Comments/suggestions appreciated:
Code:
gen byte marstat = 1 if mrcurr1 == 2 & mrcurr1[_n-1] == 2 & mrcurr2 == 2 & mrcurr2[_n-1] == 2  
replace marstat = 2 if mrcurr1 == 1 & mrcurr1[_n-1] == 2 & mrcurr2 == 1 & mrcurr2[_n-1] == 2  
replace marstat = 3 if mrcurr1 == 1 & mrcurr2 == 1 & mrcurr1[_n-1] == 1 & mrcurr2[_n-1] == 1
'mrcurr1' (male marital status); and 'mrcurr2' (female marital status) have the following categories:
Array

I want to test if there is a difference between couples that commenced prior to joining the panel study with those that formed after entering the panel study. My draft code:
Code:
gen byte in_survey = p_id != p_id[_n-1] // id (respondent id) p_id (partner's id)
One issue with this is that it seems to assume that the partner in the first panel in which a couple inters the survey is a new partner, which is generally not the case. Comments/suggestions appreciated.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long(id p_id) byte(wave mrcurr1 mrcurr2 marstat in_survey)
11  12  1 1 1 . 1
11  12  2 1 1 3 0
11  12  3 1 1 3 0
11  12  4 1 1 3 0
16 42 10 2 2 1 1
16 42 11 2 2 1 0
16 42 12 2 2 1 0
16 42 13 2 2 1 0
16 42 14 2 2 1 0
16 42 15 1 1 2 0
16 42 16 1 1 3 0
16 42 17 1 1 3 0
16 42 18 1 1 3 0
18  19  1 1 1 2 1
18  19  2 1 1 3 0
18  19  3 1 1 3 0
18  19  4 1 1 3 0
18  19  5 1 1 3 0
18  19  6 1 1 3 0
18  19  7 1 1 3 0
10 63 12 2 2 . 1
10 63 13 2 2 1 0
10 63 14 1 1 2 0
10 63 15 1 1 3 0
10 63 16 1 1 3 0
10 63 17 1 1 3 0
10 63 18 1 1 3 0
116  179  2 2 2 . 1
116  179  3 2 2 1 0
116  179  4 2 2 1 0
116  179  5 1 1 2 0
116  179  6 1 1 3 0
116  179  7 1 1 3 0
116  179  8 1 1 3 0
116  179  9 1 1 3 0
116  179 10 1 1 3 0
116 188 18 2 2 . 1
118  119  1 1 1 2 1
118  119  2 1 1 3 0
118  119  3 1 1 3 0
118  119  4 1 1 3 0
end