Hi,
I want to create a variable that tells for how many consecutive years the variable zerolev is equal to 1 before it turns 0 again. Here's an example:
The variable I want to create should look like this:
How can I create such variable? Many thanks.
I want to create a variable that tells for how many consecutive years the variable zerolev is equal to 1 before it turns 0 again. Here's an example:
Code:
fyear zerolev 1991 0 1992 0 1993 1 1994 0 1995 0 1996 1 1997 1 1998 0 1999 0 2000 0 2001 1 2002 1 2003 1 2004 0 2005 0 2006 0 2007 0 2008 0 2009 0 2010 0
The variable I want to create should look like this:
Code:
fyear zerolev newvar 1991 0 0 1992 0 0 1993 1 1 1994 0 0 1995 0 0 1996 1 0 1997 1 2 1998 0 0 1999 0 0 2000 0 0 2001 1 0 2002 1 0 2003 1 3 2004 0 0 2005 0 0 2006 0 0 2007 0 0 2008 0 0 2009 0 0 2010 0 0

Comment