On Wed, 30 Apr 2008, Stefano Balietti wrote:
Is there a way to know the name of a variable at a given
position in a list? Obviously I don't have the ID of the
variable. I knew the command: argname( variable) but it isn't
working, it returns an empty string.
argname works only for function arguments passed by name; I'm not
sure what the context is here. But here's how to do it:
<script>
open data4-10
list L = dataset
matrix Lm = L
scalar listpos = 3
scalar idnum = Lm[listpos]
printf "The variable at position %d in list L is %s\n",
listpos, varname(idnum)
</script>
This more economical version...
matrix Lm = L
scalar listpos = 3
printf "The variable at position %d in list L is %s\n",
listpos, varname(Lm[listpos])
now works, but didn't until I fixed it a few minutes ago.
Allin.