Hello,
I am wondering whether possible to build a table and attach a string value to a statistics. Here below the structure of the dataset:
I tried the following (hopefully this will help readers to understand what output I am looking for)
But get the following error:
option sformat() incorrectly specified; Aegean Oil SA does not conform to the Mata printf() format requirement for a single string argument
r(7);
The following option works, but it lists ALL the names stored in glb_name_*_* variables, i.e. also for countries in which it does not exist, and I will have to build one set of tables for each glb_name_*_* variable separately.
All in all, what I would like to have is
displaying the name stored in glb_name_*_* for each corresponding statistics.
Thanks anyway,
cheers
I am wondering whether possible to build a table and attach a string value to a statistics. Here below the structure of the dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float id int year long(enc_subcategory enc_country) str90 glbown float(glb_rnk1_sh glb_rnk2_sh) str53 glb_name_1_ str91 glb_name_2_ 169 2016 1 14 "Agorà Network Srl" 17.867418 15.239153 "Sigma Società Cooperativa" " CONAD - Consorzio Nazionale Dettaglianti Scrl" 2994 2017 12 14 "Agorà Network Srl" 9.37035 8.527388 "Coop Italia scarl" " CONAD - Consorzio Nazionale Dettaglianti Scrl" 169 2020 1 14 "Agorà Network Srl" 16.10198 9.249485 "CONAD - Consorzio Nazionale Dettaglianti Scrl" " D IT Distribuzione Italiana Soc Coop" 169 2021 1 14 "Agorà Network Srl" 18.268377 10.3335 "CONAD - Consorzio Nazionale Dettaglianti Scrl" " D IT Distribuzione Italiana Soc Coop" 2978 2022 12 14 "Agorà Network Srl" 10.914592 9.13078 "CONAD - Consorzio Nazionale Dettaglianti Scrl" " Coop Italia scarl" 169 2024 1 14 "Agorà Network Srl" 19.001884 9.727362 "CONAD - Consorzio Nazionale Dettaglianti Scrl" " D IT Distribuzione Italiana Soc Coop" 2623 2015 12 7 "Aldar Eesti OÜ" 19.763355 18.01085 "Coop Estonia" " Vilniaus Prekyba UAB" 2647 2016 12 7 "Aldar Eesti OÜ" 19.65514 17.672955 "Coop Estonia" " Vilniaus Prekyba UAB" 2647 2017 12 7 "Aldar Eesti OÜ" 20.582115 17.51535 "Coop Estonia" " Vilniaus Prekyba UAB" 2625 2018 12 7 "Aldar Eesti OÜ" 21.220295 17.525837 "Coop Estonia" " Vilniaus Prekyba UAB" 2647 2019 12 7 "Aldar Eesti OÜ" 21.96116 17.065823 "Coop Estonia" " Vilniaus Prekyba UAB" 2647 2020 12 7 "Aldar Eesti OÜ" 25.031956 18.157715 "Coop Estonia" " Tallinna Kaubamaja AS" 2625 2021 12 7 "Aldar Eesti OÜ" 25.444847 18.902826 "Coop Estonia" " Tallinna Kaubamaja AS" 2623 2022 12 7 "Aldar Eesti OÜ" 24.92241 17.692562 "Coop Estonia" " Tallinna Kaubamaja AS" 2647 2023 12 7 "Aldar Eesti OÜ" 25.006985 16.922829 "Coop Estonia" " Tallinna Kaubamaja AS" end label values enc_subcategory enc_subcategory label def enc_subcategory 1 "1. Convenience Stores", modify label def enc_subcategory 12 "12. Grocery Retailers", modify label values enc_country enc2_country label def enc2_country 7 "EE", modify label def enc2_country 14 "IT", modify
Code:
levels glb_name_1_, local(C) /*this would be repeated for all glb_name_*_* variables */ foreach c of local C { table (enc_country) (enc_subcategory year ), statistic(mean glb_rnk1_sh) nformat(%19.2fc) sformat("`c'" mean) nototals }
option sformat() incorrectly specified; Aegean Oil SA does not conform to the Mata printf() format requirement for a single string argument
r(7);
The following option works, but it lists ALL the names stored in glb_name_*_* variables, i.e. also for countries in which it does not exist, and I will have to build one set of tables for each glb_name_*_* variable separately.
Code:
table (glb_name_1_ ) (country subcategory year ), statistic(mean glb_rnk1_sh) nformat(%19.2fc) nototals
All in all, what I would like to have is
Code:
table (enc_country ) (enc_subcategory year ) , statistic(mean glb_rnk1_sh) statistic(mean glb_rnk2_sh) nformat(%19.2fc)
Thanks anyway,
cheers
Comment