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
Creating indicator variables from multiple categorical variableHello, I wanted to create an indicator variable combining two or more categorical variable. So for …
FmmHi, I have an FMM model with three class. Because the dv is binary, logistic regression is used. Le…
Questions regarding Modelling both Sample Selection Bias and Endogenous Treatment BiasDear Statalist, Hi. This is the first time I post questions on the forum. I apologize if my post is…
Panel data format: varlist as IDsHello Statalisters, I have the following daily data shape: date day city_1_price_A ... city_70_pric…
Time-series regression with varying independent variables over timeDear forum, I am new to this forum and want to ask for your opinion on a time-series regression (20…
Subscribe to:
Post Comments (Atom)
0 Response to Accumulating results with two conditions
Post a Comment