Please, help me to resolve the following issue. Below is the sample of data that I have, where “gvkey” is firm identifier, year is “fyear” and “tag5” is the number of consecutive years during which a firm was exporting its products. I need to create the following variables – firm_1, firm_2, firm_3, firm_4 and firm_5. Where “firm_1” is equal to “1” if a firm has one consecutive year of “tag5”. For example, for gvkey= 001013 “firm_1”==1 for year 2010 and zero otherwise. For gvkey = 001076 “firm_2” is equal to 1 for years=2004 and 2005. Firm_3 is for three consecutive years of “tag5” (1,2,3), Firm_4 – for 4 years of tag, Firm_5 for 5 and more consecutive years of tag5 (1,2,3,4,5,6,7,..etc). Please, help me resolve this issue.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 gvkey double fyear float tag5 "001013" 1990 . "001013" 1991 . "001013" 1992 1 "001013" 1993 2 "001013" 1994 3 "001013" 1995 4 "001013" 1996 . "001013" 1997 . "001013" 1998 . "001013" 1999 . "001013" 2000 . "001013" 2001 . "001013" 2002 . "001013" 2003 . "001013" 2004 . "001013" 2005 . "001013" 2006 . "001013" 2007 . "001013" 2008 . "001013" 2009 . "001013" 2010 1 "001076" 1994 . "001076" 1998 . "001076" 2004 1 "001076" 2005 2 "001076" 2006 . "001076" 2007 . "001076" 2008 . "001078" 1990 1 "001078" 1991 2 "001078" 1992 3 "001078" 1993 4 "001078" 1994 5 "001078" 1995 6 "001078" 1996 7 "001078" 1997 8 "001078" 1998 9 "001078" 1999 10 "001078" 2000 . "001078" 2001 . "001078" 2002 . "001078" 2003 1 "001078" 2004 2 "001078" 2005 3 end
0 Response to Create a variables based on consecutive years of observation
Post a Comment