Hi Statalist.

I want to capture the change in variables in my panel dataset, such as marital status. Below, I have grouped people into three categories, (1) those that are married (2) those that are de facto [remain as such while in a given relationship], and (3) those that start as de facto then marry. Is there a better way to code for these changes.
Code:
gen union = 1 if mrcurr==1 & p_mrcurr==1 & f1.mrcurr==1 & f1.p_mrcurr==1 // married
replace union = 2 if mrcurr==2 & p_mrcurr==2 & f1.mrcurr==2 & f1.p_mrcurr==2 // de facto
replace union = 3 if mrcurr==2 & p_mrcurr==2 & f1.mrcurr==1 & f1.p_mrcurr==1 // de facto to married
[mrcurr = marital status for the respondent; p_mrcurr = marital status for their partner]. I have an unbalanced panel with individual identifiers for both the respondent (id) and partner (p_id) and I'm running Stata v.15.1.

Comments appreciated.