Dear statalister,
I am facing a difficult problem for me to solve on stata.
I have data on footballer and football clubs as follow:
FootBaller id / Club id / Date
1 / 1 / 1995
1 / 3 / 1999
1 / 6 / 2002
2 / 3 / 1994
2 / 6 / 2005
etc..
Date is actually the year when the footballer joined a new club. My goal is to compute for each entry the number of different clubs attended in the last 5 years (for exemple here, value for _n = 1 is 1, 2 for _n = 2, 2 for _n = 2 etc...
One solution would be looping over each obs and counting, unfortunatly I have more than a million observations and this would take forever...
Thanks a lot for suggestions
Totonio
I am facing a difficult problem for me to solve on stata.
I have data on footballer and football clubs as follow:
FootBaller id / Club id / Date
1 / 1 / 1995
1 / 3 / 1999
1 / 6 / 2002
2 / 3 / 1994
2 / 6 / 2005
etc..
Date is actually the year when the footballer joined a new club. My goal is to compute for each entry the number of different clubs attended in the last 5 years (for exemple here, value for _n = 1 is 1, 2 for _n = 2, 2 for _n = 2 etc...
One solution would be looping over each obs and counting, unfortunatly I have more than a million observations and this would take forever...
Thanks a lot for suggestions
Totonio
Comment