Hi,
I wanted to generate a marital history variable in Stata. The dataset includes identifiers (pidlink), marital status (marstat), number of marriages (kwn_num), year of marriage (kw10yr), and year of separation (kw18yr). As an example, considering highlighted rows for the same person who married in 1975, separated in 2007, and remarried in 2009 until 2014, I aim to create a dummy variable set to 1 during marriage periods. Specifically, for this individual, the dummy variable should be 1 from 1988 to 2007, 0 in 2008, and 1 again from 2009 to 2014. Assistance with coding in Stata would be highly appreciated. Thank you!

I wanted to generate a marital history variable in Stata. The dataset includes identifiers (pidlink), marital status (marstat), number of marriages (kwn_num), year of marriage (kw10yr), and year of separation (kw18yr). As an example, considering highlighted rows for the same person who married in 1975, separated in 2007, and remarried in 2009 until 2014, I aim to create a dummy variable set to 1 during marriage periods. Specifically, for this individual, the dummy variable should be 1 from 1988 to 2007, 0 in 2008, and 1 again from 2009 to 2014. Assistance with coding in Stata would be highly appreciated. Thank you!
Comment