I have sales data of two years (2017 and 2018). I want to keep only top 5 firms of 2017 by sales; that is, the new data set will contain only those firms which were "top five" in 2017 by sales (That means there will be exactly 5 firms in 2017 and 2018). After that I want to reshape the data set in order to have three variables: firm, sales2017,and sales2018.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year str1 firms long sales 2017 "a" 46546 2017 "b" 2343 2017 "c" 234234 2017 "d" 34342 2017 "e" 2342 2017 "f" 2343 2017 "g" 34 2017 "h" 234 2017 "i" 6786 2018 "a" 345 2018 "b" 5675 2018 "c" 56345 2018 "d" 5675 2018 "e" 453 2018 "f" 543 2018 "g" 2342 2018 "h" 343443 2018 "i" 234 2018 "j" 343 end
Comment