I would like to fill in the cell with a variable name showing the highest value in a row from the variables list. In other words, if there are variables A,b and C, and their weights are 1.5, 1.6, and 1.9, respectively, I would like to show 'A' because the variable presenting highest number in a row. This is totally same to the previous post. https://www.statalist.org/forums/for...ariables-names
However, my code returns 'no observations'.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(Ashley Avonmouth Bedminster) .47862031997167737 1.532034471353277 .335260066474374 194.98321551370202 765.8470150728051 862.8241100970403 1.0459228370345555 1.6267469649369481 .36140040372976157 .47862031997167737 1.532034471353277 .335260066474374 1.6624821901728994 5.725894733221313 3.0836531482405807 end
Code:
local vars Ashley-Bedminster *local vars Ashley-WindmillHill egen m2=rowmax(`vars') gen m="" foreach var of local vars { replace m = "`var'" if m2==`vars' } tab m
Kind regards,
Kim
0 Response to extract variable name when the observation has a highest value.
Post a Comment