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
Related Posts with Accumulating results with two conditions
Accounting for time difference in forecasts when using repeated cross sectional dataI need to forecast repeated cross sectional data (survey data) with (dep. var.) monthly electricity…
Taking a midpoint of quarterI have two numeric variables labeled quarter (1,2,3,4) and year. I want to generate a new variable t…
Interpreting a fixed effects regression whether the treatment variable is binaryHello all, There have been similar posts about this interpretation but I can't find any with the sa…
Returning the name of a variable that takes on the maximum value within a set of other variables?Hey folks. I have a dataset with respondents reporting how many visits they took to certain recreati…
multinomial logit questionI am trying to run a multinomial logit as y being the number of credit cards an individual has. I re…
Subscribe to:
Post Comments (Atom)
0 Response to Accumulating results with two conditions
Post a Comment