Hello!

I want to accumulate values from the first occurrences or the first row given a specific round and a specific ID. E.g. see Table below. X represents the accumulated investment from each round. Round 1 equals 100 and round 2 equals 250, hence the accumulated value for round 2 is 250. The problem is that we have duplicate values due to time variables (e.g. round 1 has investment = 100 twice, but the total investment in round 1 equals 100 and not 100+100).

I have tried the following solution: bysort ID (Round): gen x = sum(Investment). Although it resulted in that all the X: es were summarized together. Furthermore, I tried the following method: bysort ID(Round): egen x = sum(mean(Investment)) but it did not work as I hoped in Stata.

To summarize: I want to either summarize the average of each x condition on its round and ID until Round and ID ... n. Or summarize only the first observation for each round for every id. The result should give me information on the accumulation of investment amount (x) in round 2....n and be connected to the ID.

Any help is much appreciated, thank you in advance!
ID Round Investment (observation) x
1 1 100 100
1 1 100 100
1 2 150 250
1 2 150 250
2 1 200 200
2 1 200 200
2 1 200 200
2 2 300 500
2 2 300 500