Hi Guys,
I have a panel of frequencies looking like
# ID Year Freq
1 1 2000 2
2 1 2001 3
3 1 2002 2
4 2 2000 0
5 2 2001 3
6 2 2002 5
I have more than 2000 IDs and around 20 years. I want to change this to a cumulative version where for each id values of freq will sum up over time like
Version 2
# ID Year Freq
1 1 2000 2
2 1 2001 5
3 1 2002 7
4 2 2000 0
5 2 2001 3
6 2 2002 8
I think I can switch my panel to a wide version and then sum the values using a loop, but I was wondering if there are any other ways to approach this problem in this long format.
And if I have to switch it to wide, what would be the best way I can define my loop to go over years for each id and sum the values year by year?
Thanks for the help.
Leila
I have a panel of frequencies looking like
# ID Year Freq
1 1 2000 2
2 1 2001 3
3 1 2002 2
4 2 2000 0
5 2 2001 3
6 2 2002 5
I have more than 2000 IDs and around 20 years. I want to change this to a cumulative version where for each id values of freq will sum up over time like
Version 2
# ID Year Freq
1 1 2000 2
2 1 2001 5
3 1 2002 7
4 2 2000 0
5 2 2001 3
6 2 2002 8
I think I can switch my panel to a wide version and then sum the values using a loop, but I was wondering if there are any other ways to approach this problem in this long format.
And if I have to switch it to wide, what would be the best way I can define my loop to go over years for each id and sum the values year by year?
Thanks for the help.
Leila
Comment