The original dataset has the following structure:

group_id | year | varx
1 1998 5
1 1998 5
1 1999 2
2 1998 1
2 1998 1
2 1998 1
2 1999 3


The outcome should look like:

group_id | year | varx
1 1998 10
1 1999 2
2 1998 3
2 1999 3


Thank you for your suggestions!