Hi!
I am trying to create a variable for cumulative employment experience for my panel data out of employment spells data.
I have two data sets:
-One has start years and end years of employment spells for each person.
e.g.
Person No. Start Year End Year
1 1971 1976
1 1979 1980
1 1985 1993
1 1993 2005
2 1974 1979
2 1993 1997
2 1999 2009
3 1976 2009
4 1973 1981
4 1985 2007
etc
-One has all the person numbers for each year of the survey, which covers 1991 to 2009. I would like to make the EmploymentExperience variable.
Person No. Year Variable1 Variable2 Variable3 EmploymentExperience
1 1991
1 1992
1 1993
1 1994
... ....
1 2009
2 1991
2 1992
2 1993
etc
With the first data set, using end year - start year, summing them all up and sorting by person number, I can see what each persons TOTAL EMPLOYMENT EXPERIENCE UP TO 2009 is.
E.g.
Person No. Start Year End Year TotEmp
1 1971 1976 26
1 1979 1980 26
1 1985 1993 26
1 1993 2005 26
2 1974 1979 19
2 1993 1997 19
2 1999 2009 19
3 1976 2009 33
4 1973 1981 30
4 1985 2007 30
However, I need this to be cumulative for each survey year.
E.g. for person 2, their total employment experience up to 2009 is 19 years, but I need to calculate it for each survey year. i.e. I need to come up with this
Person Number Year EmploymentExperience
1 1991 5
1 1992 5
1 1993 5
1 1994 6
1 1995 7
1 1996 8
1 1997 9
1 1998 9
1 1999 9
etc up to
1 2009 19
And then I can conduct my panel regression, with wage as the y variable and employment experience as one of the x variables for each year 1991-2009.
I could do this manually however I have thousands of observations so this wouldn't be possible.
I need to find some way to generate this command. Any suggestions would be much appreciated.
Thanks!
I am trying to create a variable for cumulative employment experience for my panel data out of employment spells data.
I have two data sets:
-One has start years and end years of employment spells for each person.
e.g.
Person No. Start Year End Year
1 1971 1976
1 1979 1980
1 1985 1993
1 1993 2005
2 1974 1979
2 1993 1997
2 1999 2009
3 1976 2009
4 1973 1981
4 1985 2007
etc
-One has all the person numbers for each year of the survey, which covers 1991 to 2009. I would like to make the EmploymentExperience variable.
Person No. Year Variable1 Variable2 Variable3 EmploymentExperience
1 1991
1 1992
1 1993
1 1994
... ....
1 2009
2 1991
2 1992
2 1993
etc
With the first data set, using end year - start year, summing them all up and sorting by person number, I can see what each persons TOTAL EMPLOYMENT EXPERIENCE UP TO 2009 is.
E.g.
Person No. Start Year End Year TotEmp
1 1971 1976 26
1 1979 1980 26
1 1985 1993 26
1 1993 2005 26
2 1974 1979 19
2 1993 1997 19
2 1999 2009 19
3 1976 2009 33
4 1973 1981 30
4 1985 2007 30
However, I need this to be cumulative for each survey year.
E.g. for person 2, their total employment experience up to 2009 is 19 years, but I need to calculate it for each survey year. i.e. I need to come up with this
Person Number Year EmploymentExperience
1 1991 5
1 1992 5
1 1993 5
1 1994 6
1 1995 7
1 1996 8
1 1997 9
1 1998 9
1 1999 9
etc up to
1 2009 19
And then I can conduct my panel regression, with wage as the y variable and employment experience as one of the x variables for each year 1991-2009.
I could do this manually however I have thousands of observations so this wouldn't be possible.
I need to find some way to generate this command. Any suggestions would be much appreciated.
Thanks!

Comment