Hello everybody,

I am working on a dataset right now and need to know a simple thing. The dataset looks roughly like this:
votes key
5 1
7 1
2 1
4 2
6 2
8 2
3 3
8 3
9 3
As you might have guessed I want to sum all votes with the same key and generate a new variable with as many rows as i have individual keys (in this case 3 rows):
votes key
14 1
18 2
20 3
using "egen votes2 = sum(votes), by(key)" I receive the original number of rows and the sum repeatedly.

I am kinda confused even though it probably is very easy to solve.

greetings
Felix