Dear All, Suppose the data set is:
For each id, I want to replace all the values with the one with highest frequency. For instance, all the values for id=1 should be 0 (with highest frequency). Similarly, for id=2, all the values should be -196.3000030518, and so on. Any suggestions are appreciated!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str75 firmname double profit float(profitsd id) "中科搏锐(北京)科技有限公司" 0 14.516553 1 "中科搏锐(北京)科技有限公司" 0 14.516553 1 "中科搏锐(北京)科技有限公司" -32.459999084472656 14.516553 1 "中科搏锐(北京)科技有限公司" 0 14.516553 1 "中科搏锐(北京)科技有限公司" 0 14.516553 1 "中米(北京)农业科技股份有限公司" -196.3000030517578 82.23363 2 "中米(北京)农业科技股份有限公司" -196.3000030517578 82.23363 2 "中米(北京)农业科技股份有限公司" -196.3000030517578 82.23363 2 "中米(北京)农业科技股份有限公司" -12.420000076293945 82.23363 2 "中米(北京)农业科技股份有限公司" -196.3000030517578 82.23363 2 "优伴(北京)文化产业有限公司" 0 45.66051 3 "优伴(北京)文化产业有限公司" 0 45.66051 3 "优伴(北京)文化产业有限公司" 0 45.66051 3 "优伴(北京)文化产业有限公司" -102.0999984741211 45.66051 3 "优伴(北京)文化产业有限公司" 0 45.66051 3 "北京万合鸿瑞科技有限公司" 8.699999809265137 8.322645 4 "北京万合鸿瑞科技有限公司" -9.90999984741211 8.322645 4 "北京万合鸿瑞科技有限公司" 8.699999809265137 8.322645 4 "北京万合鸿瑞科技有限公司" 8.699999809265137 8.322645 4 "北京万合鸿瑞科技有限公司" 8.699999809265137 8.322645 4 end
Comment