Dear all,

#<hansl

function string get_rnames(matrix M)
   string s = sprintf("%d",M)
   nss = nlines(s)
   string line
   scalar i = 1
   strings S = array(nss)
   loop while getline(s, line) -q
       S[i]= sprintf("%s",  line)
       i++
   endloop
   ret = ""
   if nelem(strsplit(S[1])) == 2
       loop i = 1..nss -q
           ret = ret~" "~strsplit(S[i])[1]
       endloop
       ret = strstrip(ret)
   endif
   return ret
end function

# example
M = I(2)
M[1,1] = NA
rownames(M, "a b")
eval get_rnames(M)

#hansl>

output:
? eval get_rnames(M)
a b

Is there a less roundabout way to extract row names
of a matrix

Oleh