Hi everyone,
I need to combine the observations and calculate the sum in my dataset. Please see the example below:
And I need to combine the observations within the same year, brand, and size, and then sum up their unit and revenue, respectively, so the result should look at this:
How could I do this in Stata? Thank you!
I need to combine the observations and calculate the sum in my dataset. Please see the example below:
Year | Brand | Size | Unit | Revenue | |
1 | 2010 | A | 1 | 100 | 10000 |
2 | 2010 | A | 1 | 200 | 20000 |
3 | 2010 | B | 3 | 100 | 30000 |
4 | 2011 | A | 2 | 100 | 15000 |
5 | 2011 | B | 1 | 100 | 8000 |
6 | 2011 | B | 2 | 200 | 26000 |
7 | 2011 | B | 2 | 200 | 27000 |
8 | 2012 | C | 1 | 100 | 9000 |
9 | 2012 | C | 3 | 100 | 40000 |
10 | 2012 | C | 3 | 300 | 120000 |
Year | Brand | Size | Unit | Revenue | |
1 | 2010 | A | 1 | 300 | 30000 |
2 | 2010 | B | 3 | 100 | 30000 |
3 | 2011 | A | 2 | 100 | 15000 |
4 | 2011 | B | 1 | 100 | 8000 |
5 | 2011 | B | 2 | 400 | 53000 |
6 | 2012 | C | 1 | 100 | 9000 |
7 | 2012 | C | 3 | 400 | 160000 |
Comment