Hello,

I have data about the video game industry and I would like to add a control variable that represents the accumulated sales of previous entries in a certain game franchise (e.g. MW2 is an entry in the Call of Duty franchise). This is how a small sample would look:

Franchise Entry Globalsales
A 1 1.27
B 1 2.21
C 1 1.3
C 2 2.41
C 3 2.18
C 4 1.57
C 5 1.2
D 1 3.17
D 2 1.71
D 3 1.01
D 4 1.23


Ultimately it should look like this:

Franchise Entry Globalsales Accumulated_Franchise_sales
A 1 1.27 0
B 1 2.21 0
C 1 1.3 0
C 2 2.41 1.3
C 3 2.18 2.71
C 4 1.57 4.59
C 5 1.2 5.79
D 1 3.17 0
D 2 1.71 3.17
D 3 1.01 4.18
D 4 1.23 5.41

I tried the following commands which did not provide the desired result:

bysort Entry Franchise: egen Accumulated_Franchise_Sales = sum(Globalsales)
bysort Franchise Entry: egen Accumulated_Franchise_Sales = sum(Globalsales)

Could someone please help me with finding a command that would provide the desired result?

Yannick