What I am trying to do is identify all people who have reported being married but for two or more years they have reported no status. This is based on panel data 1984-2015. There is missing data in between status of being married. I tried using the below command (pid=perosnal ID, marstatus =1 if the person is married):
by pid syear: gen cutoff=(marstatus!=marstatus[_n-1]) if marstatus ==1
by pid: gen spell=sum(cutoff)
by pid spell (syear), sort: gen spell_l = _N
recode cutoff (.=0)
However I still cannot manage. I wan to remove for example this person who has no reported status between 1987 and 1989. However for every person those years might be defferent
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte marstatus int syear long pid float(spell length cutoff) 1 1984 3202 1 1 1 1 1985 3202 2 1 1 1 1986 3202 3 4 1 . 1987 3202 3 4 0 . 1988 3202 3 4 0 . 1989 3202 3 4 0 1 1990 3202 4 26 1 . 1991 3202 4 26 0 . 1992 3202 4 26 0 . 1993 3202 4 26 0 . 1994 3202 4 26 0 . 1995 3202 4 26 0 . 1996 3202 4 26 0 . 1997 3202 4 26 0 . 1998 3202 4 26 0 . 1999 3202 4 26 0 . 2000 3202 4 26 0 . 2001 3202 4 26 0 . 2002 3202 4 26 0 . 2003 3202 4 26 0 . 2004 3202 4 26 0 . 2005 3202 4 26 0 . 2006 3202 4 26 0 . 2007 3202 4 26 0 . 2008 3202 4 26 0 . 2009 3202 4 26 0 . 2010 3202 4 26 0 . 2011 3202 4 26 0 . 2012 3202 4 26 0 . 2013 3202 4 26 0 . 2014 3202 4 26 0 . 2015 3202 4 26 0 end label values marstatus d11104 label def d11104 1 "[1] Married 1", modify
0 Response to Missing marital status between years
Post a Comment