I want to calculate the age of a company.
in output I need to add another column showing age = No of year a specific company (gvkey) is appeared in the data set.
out put
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 gvkey double fyear "147329" 2006 "001003" 1989 "128178" 1999 "128178" 2000 "021542" 1993 "021542" 1994 "021542" 1995 "021542" 1996 "021542" 2005 "021542" 2006 "001004" 1989 "001004" 1990 "001004" 1991 end
in output I need to add another column showing age = No of year a specific company (gvkey) is appeared in the data set.
out put
gvkey | fyear | age |
147329 | 2006 | 1 |
001003 | 1989 | 1 |
128178 | 1999 | 2 |
128178 | 2000 | 2 |
021542 | 1993 | 6 |
021542 | 1994 | 6 |
021542 | 1995 | 6 |
021542 | 1996 | 6 |
021542 | 2005 | 6 |
021542 | 2006 | 6 |
001004 | 1989 | 3 |
001004 | 1990 | 3 |
001004 | 1991 | 3 |
Comment