Hi,
I have a panel dataset like below.
data have;
input FirmID $ Year Count;
datalines;
1001 1992 1
1001 1993 2
1001 1994 3
1001 1995 4
1001 1996 5
1001 1997 5
1002 1992 6
1002 1993 7
1002 1994 8
1002 1995 9
1002 1996 8
1002 1997 7
;
I would like to get the sum of the count in the previous 3 years. For example, Pre3 in 1995 is 6 (1+2+3). The result I want is below.
FirmID Year Count Pre3
1001 1992 1 .
1001 1993 2 .
1001 1994 3 .
1001 1995 4 6
1001 1996 5 9
1001 1997 5 12
1002 1992 6 .
1002 1993 7 .
1002 1994 8 .
1002 1995 9 21
1002 1996 8 24
1002 1997 7 25
What program do I need to use?