Hey everyone, I'm new to Stata and have a question.
I need to aggregate the data by year and company. With the collapse function, I can only sum up the values for the companies for all years.
The raw data look like this:
id year companyid sales
1 2010 555 50,000
2 2010 555 46,000
3 2010 555 40,000
4 2011 555 30,000
5 2011 555 51,000
6 2010 700 2,000
7 2010 700 4,000
8 2011 700 7,000
9 2011 700 11,000
10 2011 700 5,000
.....
The result I need, should look like this:
year companyid Sum
2010 555 136,000
2010 700 6,000
2011 555 81,000
2011 700 23,000
.....
I appreciate any thoughts, many thanks!
Related Posts with Aggregate data by TWO groups
Doubts about interpretation of the estimated coefficients using a stochastic frontier modelIn my thesis, I´m estiming a stochastic frontier model (SFM). The first equation estimates the produ…
how can I generate a dummy variable based on another dummy variable?Hi all, my data pretty much looks like the following Code: Year company var1 1999 CompanyA 0 200…
Issue with histogram: Single outlier and x-axis scaleI have uploaded a .png of my experimental histogram. The code for it is as follows Code: histogr…
Looping correlation between variablesHi, With following data: Code: * Example generated by -dataex-. To install: ssc install dataex cle…
Interaction with instrumented variableI am measuring the impact of distance to the nearest city on employment outcomes. Y = b0 + b1*X1 + …
Subscribe to:
Post Comments (Atom)
0 Response to Aggregate data by TWO groups
Post a Comment