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

st: MATA: Dynamic Variable Names in MATA

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


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

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

* For searches and help try:

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