I am trying to get row name of a max value in a matrix. Previously i did install matsort and tabstatmat and mix both commands with st_matrixrowstripe but fail in the last step, my example code
Code:
sysuse auto, clear
*previously install tabstatmat
tabstat mpg, by(foreig) stat(mean sd) save
tabstatmat x, nototal
*previously install matsort
matsort x 1 "down"
mat li x
mean sd
Domestic:mpg 24.772727 6.6111869
Foreign:mpg 19.826923 4.7432972
local max = x[1,1]
mata : st_matrixrowstripe("x")
1 2
+-----------------------+
1 | Domestic mpg |
2 | Foreign mpg |
+-----------------------+
local rownames = x[1,1]
di "`rownames'"
Best regards
0 Response to How get rowname of max value using matsort, tabstatmat and st_matrixrowstripe
Post a Comment