Hi,
I have a panel dataset with variables id, t (year), and the number of children between 0-3 y.o. present in the household. So if an individual gives birth, I can see that the variable number of children between 0-3 y.o. becomes 1 for 4 consecutive years.
Based on this data, I would like to code the years in which each individual gives birth (first_birth, second_birth, etc)
The data looks like this
How can I code it in a way that it shows that for individual one, first_birth=2001 and second_birth=2007 and for individual 2, first_birth=1995 and second_birth=1997?
Thanks
I have a panel dataset with variables id, t (year), and the number of children between 0-3 y.o. present in the household. So if an individual gives birth, I can see that the variable number of children between 0-3 y.o. becomes 1 for 4 consecutive years.
Based on this data, I would like to code the years in which each individual gives birth (first_birth, second_birth, etc)
The data looks like this
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id t num_children_0_3) 1 2000 0 1 2001 1 1 2002 1 1 2003 1 1 2004 1 1 2005 0 1 2006 0 1 2007 1 1 2008 1 2 1995 1 2 1996 1 2 1997 2 2 1998 2 2 1999 1 2 2000 1 2 2001 0 3 2002 0 3 2003 0 3 2004 0 3 2005 1 3 2006 1 3 2007 1 3 2008 1 3 2009 0 3 2010 0 3 2011 0 3 2012 0 end
Thanks

Comment