Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: MATA: Dynamic Variable Names in MATA


From   Nicholas Harrigan <[email protected]>
To   [email protected]
Subject   st: MATA: Dynamic Variable Names in MATA
Date   Sat, 22 Mar 2008 12:12:20 +0000

Hi,

Is there anyway of dynamically generating variable names in MATA?

For example, I would like to be able to write something like this:

count = 10
for(x=1; x<=count; x++) {
y = strofreal(x)
hello_`y' = x*10
}

and is this way generate 10 variables named hello_1, hello_2, ... hello_10.

I know that the STATA local ` ' syntax doesn't work in MATA, but it would be very very helpful to me to be able to be able to dynamically generate variables in MATA.

If there isn't anyway of dynamically generating variables in MATA, are there any work arounds you suggest?

Thanks and best wishes
Nick

--
Nicholas Harrigan
Post-doctoral research officer
Nuffield College, Oxford, OX1 1NF
Ph: +44 (0) 18652 78548
M: +44 (0) 7962 627960
[email protected]

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index