I don't understand the variables spell_duration and total_duration_this pair, as they do not look like they could have been created by the code we have discussed in this thread. So I'm just going to ignore them.
If I understand your question correctly you just want a variable that shows the total number of waves in which a couple reports being in a relationship, whether those waves or consecutive or not. If so, that's not too hard:
If I understand your question correctly you just want a variable that shows the total number of waves in which a couple reports being in a relationship, whether those waves or consecutive or not. If so, that's not too hard:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(id p_id) byte(wave mrcurr1 mrcurr2) 100001 100002 1 1 1 100001 100002 2 1 1 100001 100002 3 1 1 100001 100002 4 1 1 100003 100004 1 1 1 100003 100004 2 1 1 100003 100004 3 1 1 100003 100004 4 1 1 100006 1000842 10 2 2 100006 1000842 11 2 2 100006 1000842 12 2 2 100006 1000842 13 2 2 100006 1000842 14 2 2 100006 1000842 15 1 1 100006 1000842 16 1 1 100006 1000842 17 1 1 100006 1000842 18 1 1 100007 1106359 11 2 2 100008 100009 1 1 1 100008 100009 2 1 1 100008 100009 3 1 1 100008 100009 4 1 1 100008 100009 5 1 1 100008 100009 6 1 1 100008 100009 7 1 1 100011 600231 6 2 2 100011 600231 7 2 2 100011 600231 8 2 2 100011 600231 9 2 2 100016 200179 2 2 2 100016 200179 3 2 2 100016 200179 4 2 2 100016 200179 5 1 1 100016 200179 6 1 1 100016 200179 7 1 1 100016 200179 8 1 1 100016 200179 9 1 1 100016 200179 10 1 1 100016 1800788 18 2 2 end gen byte in_relationship = inlist(mrcurr1, 1, 2) if !missing(mrcurr1) replace in_relationship = inlist(mrcurr2, 1, 2) if missing(in_relationship) by id p_id (wave), sort: egen number_of_waves_in_relationship = total(in_relationship)
Comment