This may help:
If you type "index" Mata understands that the local macro is to be named, literally, index.
If you type index Mata understands that the name to be used for the macro is itself a scalar called index already defined to Mata. But it can't find such a beast.
That's my interpretation.
Note that a literal "varname" won't work unless that really is a name in your dataset.
Code:
. sysuse auto, clear (1978 automobile data) . mata: st_local(index, strofreal(st_varindex("mpg"))) <istmt>: 3499 index not found r(3499); . mata: st_local("index", strofreal(st_varindex("mpg"))) . di "`index'" 3
If you type index Mata understands that the name to be used for the macro is itself a scalar called index already defined to Mata. But it can't find such a beast.
That's my interpretation.
Note that a literal "varname" won't work unless that really is a name in your dataset.
Comment