I have a dataset consisting of a large number of different products and their monthly import between June 2017-June 2019 as unit prices with including tariffs (unit_p_tariffinc). I would like to sum these values for every and each product for all month.
I know that it can be done for each at a time by
Code:
sum unit_p_tariffinc if product=="01011010" display r(sum)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 product long product_ str14 valueQUANTITY_IN_100KG long quantity_in_100kg str14 valueVALUE_IN_EUROS double value_in_euros str4 y_m float(dummy tariff unit_price unit_p_tariffinc product_sum totalsum_treated weight) int(year month) float mdate "01011010" 1011010 ":" . ":" . "1906" 0 1 . . 0 . . 2019 6 713 "01011010" 1011010 ":" . ":" . "1804" 0 1 . . 0 . . 2018 4 699 "01011010" 1011010 ":" . ":" . "1803" 0 1 . . 0 . . 2018 3 698 "01011010" 1011010 ":" . ":" . "1802" 0 1 . . 0 . . 2018 2 697 "01011010" 1011010 ":" . ":" . "1810" 0 1 . . 0 . . 2018 10 705 "01011010" 1011010 ":" . ":" . "1905" 0 1 . . 0 . . 2019 5 712 "01011010" 1011010 ":" . ":" . "1811" 0 1 . . 0 . . 2018 11 706 "01011010" 1011010 ":" . ":" . "1710" 0 1 . . 0 . . 2017 10 693 "01011010" 1011010 ":" . ":" . "1901" 0 1 . . 0 . . 2019 1 708 "01011010" 1011010 ":" . ":" . "1707" 0 1 . . 0 . . 2017 7 690 "01011010" 1011010 ":" . ":" . "1805" 0 1 . . 0 . . 2018 5 700 "01011010" 1011010 ":" . ":" . "1902" 0 1 . . 0 . . 2019 2 709 "01011010" 1011010 ":" . ":" . "1812" 0 1 . . 0 . . 2018 12 707 "01011010" 1011010 ":" . ":" . "1706" 0 1 . . 0 . . 2017 6 689 "01011010" 1011010 ":" . ":" . "1712" 0 1 . . 0 . . 2017 12 695 "01011010" 1011010 ":" . ":" . "1806" 0 1 . . 0 . . 2018 6 701 "01011010" 1011010 ":" . ":" . "1801" 0 1 . . 0 . . 2018 1 696 "01011010" 1011010 ":" . ":" . "1904" 0 1 . . 0 . . 2019 4 711 "01011010" 1011010 ":" . ":" . "1708" 0 1 . . 0 . . 2017 8 691 "01011010" 1011010 ":" . ":" . "1709" 0 1 . . 0 . . 2017 9 692 "01011010" 1011010 ":" . ":" . "1903" 0 1 . . 0 . . 2019 3 710 "01011010" 1011010 ":" . ":" . "1808" 0 1 . . 0 . . 2018 8 703 "01011010" 1011010 ":" . ":" . "1807" 0 1 . . 0 . . 2018 7 702 "01011010" 1011010 ":" . ":" . "1711" 0 1 . . 0 . . 2017 11 694 "01011010" 1011010 ":" . ":" . "1809" 0 1 . . 0 . . 2018 9 704 "01011090" 1011090 ":" . ":" . "1709" 0 1 . . 0 . . 2017 9 692 "01011090" 1011090 ":" . ":" . "1710" 0 1 . . 0 . . 2017 10 693 "01011090" 1011090 ":" . ":" . "1902" 0 1 . . 0 . . 2019 2 709 "01011090" 1011090 ":" . ":" . "1905" 0 1 . . 0 . . 2019 5 712 "01011090" 1011090 ":" . ":" . "1802" 0 1 . . 0 . . 2018 2 697 "01011090" 1011090 ":" . ":" . "1807" 0 1 . . 0 . . 2018 7 702 "01011090" 1011090 ":" . ":" . "1809" 0 1 . . 0 . . 2018 9 704 "01011090" 1011090 ":" . ":" . "1804" 0 1 . . 0 . . 2018 4 699 "01011090" 1011090 ":" . ":" . "1906" 0 1 . . 0 . . 2019 6 713 "01011090" 1011090 ":" . ":" . "1805" 0 1 . . 0 . . 2018 5 700 "01011090" 1011090 ":" . ":" . "1708" 0 1 . . 0 . . 2017 8 691 "01011090" 1011090 ":" . ":" . "1803" 0 1 . . 0 . . 2018 3 698 "01011090" 1011090 ":" . ":" . "1904" 0 1 . . 0 . . 2019 4 711 "01011090" 1011090 ":" . ":" . "1808" 0 1 . . 0 . . 2018 8 703 "01011090" 1011090 ":" . ":" . "1706" 0 1 . . 0 . . 2017 6 689 "01011090" 1011090 ":" . ":" . "1901" 0 1 . . 0 . . 2019 1 708 "01011090" 1011090 ":" . ":" . "1810" 0 1 . . 0 . . 2018 10 705 "01011090" 1011090 ":" . ":" . "1806" 0 1 . . 0 . . 2018 6 701 "01011090" 1011090 ":" . ":" . "1707" 0 1 . . 0 . . 2017 7 690 "01011090" 1011090 ":" . ":" . "1712" 0 1 . . 0 . . 2017 12 695 "01011090" 1011090 ":" . ":" . "1811" 0 1 . . 0 . . 2018 11 706 "01011090" 1011090 ":" . ":" . "1711" 0 1 . . 0 . . 2017 11 694 "01011090" 1011090 ":" . ":" . "1903" 0 1 . . 0 . . 2019 3 710 "01011090" 1011090 ":" . ":" . "1812" 0 1 . . 0 . . 2018 12 707 "01011090" 1011090 ":" . ":" . "1801" 0 1 . . 0 . . 2018 1 696 "01011100" 1011100 ":" . ":" . "1903" 0 1 . . 0 . . 2019 3 710 "01011100" 1011100 ":" . ":" . "1808" 0 1 . . 0 . . 2018 8 703 "01011100" 1011100 ":" . ":" . "1906" 0 1 . . 0 . . 2019 6 713 "01011100" 1011100 ":" . ":" . "1809" 0 1 . . 0 . . 2018 9 704 "01011100" 1011100 ":" . ":" . "1804" 0 1 . . 0 . . 2018 4 699 "01011100" 1011100 ":" . ":" . "1806" 0 1 . . 0 . . 2018 6 701 "01011100" 1011100 ":" . ":" . "1712" 0 1 . . 0 . . 2017 12 695 "01011100" 1011100 ":" . ":" . "1707" 0 1 . . 0 . . 2017 7 690 "01011100" 1011100 ":" . ":" . "1810" 0 1 . . 0 . . 2018 10 705 "01011100" 1011100 ":" . ":" . "1807" 0 1 . . 0 . . 2018 7 702 "01011100" 1011100 ":" . ":" . "1811" 0 1 . . 0 . . 2018 11 706 "01011100" 1011100 ":" . ":" . "1812" 0 1 . . 0 . . 2018 12 707 "01011100" 1011100 ":" . ":" . "1905" 0 1 . . 0 . . 2019 5 712 "01011100" 1011100 ":" . ":" . "1711" 0 1 . . 0 . . 2017 11 694 "01011100" 1011100 ":" . ":" . "1802" 0 1 . . 0 . . 2018 2 697 "01011100" 1011100 ":" . ":" . "1904" 0 1 . . 0 . . 2019 4 711 "01011100" 1011100 ":" . ":" . "1706" 0 1 . . 0 . . 2017 6 689 "01011100" 1011100 ":" . ":" . "1805" 0 1 . . 0 . . 2018 5 700 "01011100" 1011100 ":" . ":" . "1902" 0 1 . . 0 . . 2019 2 709 "01011100" 1011100 ":" . ":" . "1801" 0 1 . . 0 . . 2018 1 696 "01011100" 1011100 ":" . ":" . "1901" 0 1 . . 0 . . 2019 1 708 "01011100" 1011100 ":" . ":" . "1709" 0 1 . . 0 . . 2017 9 692 "01011100" 1011100 ":" . ":" . "1708" 0 1 . . 0 . . 2017 8 691 "01011100" 1011100 ":" . ":" . "1803" 0 1 . . 0 . . 2018 3 698 "01011100" 1011100 ":" . ":" . "1710" 0 1 . . 0 . . 2017 10 693 "01011910" 1011910 ":" . ":" . "1708" 0 1 . . 0 . . 2017 8 691 "01011910" 1011910 ":" . ":" . "1804" 0 1 . . 0 . . 2018 4 699 "01011910" 1011910 ":" . ":" . "1805" 0 1 . . 0 . . 2018 5 700 "01011910" 1011910 ":" . ":" . "1806" 0 1 . . 0 . . 2018 6 701 "01011910" 1011910 ":" . ":" . "1901" 0 1 . . 0 . . 2019 1 708 "01011910" 1011910 ":" . ":" . "1801" 0 1 . . 0 . . 2018 1 696 "01011910" 1011910 ":" . ":" . "1803" 0 1 . . 0 . . 2018 3 698 "01011910" 1011910 ":" . ":" . "1906" 0 1 . . 0 . . 2019 6 713 "01011910" 1011910 ":" . ":" . "1903" 0 1 . . 0 . . 2019 3 710 "01011910" 1011910 ":" . ":" . "1904" 0 1 . . 0 . . 2019 4 711 "01011910" 1011910 ":" . ":" . "1710" 0 1 . . 0 . . 2017 10 693 "01011910" 1011910 ":" . ":" . "1711" 0 1 . . 0 . . 2017 11 694 "01011910" 1011910 ":" . ":" . "1808" 0 1 . . 0 . . 2018 8 703 "01011910" 1011910 ":" . ":" . "1905" 0 1 . . 0 . . 2019 5 712 "01011910" 1011910 ":" . ":" . "1807" 0 1 . . 0 . . 2018 7 702 "01011910" 1011910 ":" . ":" . "1712" 0 1 . . 0 . . 2017 12 695 "01011910" 1011910 ":" . ":" . "1802" 0 1 . . 0 . . 2018 2 697 "01011910" 1011910 ":" . ":" . "1707" 0 1 . . 0 . . 2017 7 690 "01011910" 1011910 ":" . ":" . "1810" 0 1 . . 0 . . 2018 10 705 "01011910" 1011910 ":" . ":" . "1709" 0 1 . . 0 . . 2017 9 692 "01011910" 1011910 ":" . ":" . "1809" 0 1 . . 0 . . 2018 9 704 "01011910" 1011910 ":" . ":" . "1812" 0 1 . . 0 . . 2018 12 707 "01011910" 1011910 ":" . ":" . "1706" 0 1 . . 0 . . 2017 6 689 "01011910" 1011910 ":" . ":" . "1902" 0 1 . . 0 . . 2019 2 709 "01011910" 1011910 ":" . ":" . "1811" 0 1 . . 0 . . 2018 11 706 end format %tm mdate
Thanks in advance!
0 Response to Generate summed variables
Post a Comment