Hi everyone,
In Mata, I am trying to work with temporary variables, but I am having trouble accesing them from Stata. For instance, if I use st_tempname() to create one temporary variable, "temp_var", the code works in creating the temporary variable, but I can't access it from Stata as `temp_var', only with the temporary name of the first variable, __000000.
If I wanted to create even more temporary variables, st_tempname()'s documentation doesn't even mention how you can name them. For instance, here I create 11 temporary variables, and the only way to access them is with their names, __000000 to __00000A.
How can I call these variables from Stata? Calling them as __0000* is not ideal, since after 10 variables the naming pattern changes to letters (__00000A), and these names will change if there are other temporary variables already defined.
In Mata, I am trying to work with temporary variables, but I am having trouble accesing them from Stata. For instance, if I use st_tempname() to create one temporary variable, "temp_var", the code works in creating the temporary variable, but I can't access it from Stata as `temp_var', only with the temporary name of the first variable, __000000.
Code:
sysuse auto, clear mata: st_addvar("double", temp_var=st_tempname()) mata: st_store(.,temp_var, rnormal(74,1,10,100)) summ __000000 summ `temp_var'
If I wanted to create even more temporary variables, st_tempname()'s documentation doesn't even mention how you can name them. For instance, here I create 11 temporary variables, and the only way to access them is with their names, __000000 to __00000A.
Code:
mata: idx=st_addvar("double", st_tempname(11)) mata: st_store(.,idx, rnormal(74,11,10,100)) summ __*
Comment