[Gretl-users] variable names

Allin Cottrell cottrell at wfu.edu
Wed Apr 30 10:54:20 EDT 2008


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.


More information about the Gretl-users mailing list