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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: MATA: dynamically generating variable names in MATA |

Date |
Sun, 23 Mar 2008 08:46:34 -0400 |

What you describe below creates variables equal to constants, which is not a good idea in Stata. If you want to have a set of scalar values taking on specific values, use the scalar command in Stata. You can, as others have suggested, do something similar with matrix elements in Mata (which, like Stata, is not an acronym). You can also use Mata pointers to create a set of temporary variables in Mata.

Kit Baum, Boston College Economics and DIW Berlin

http://ideas.repec.org/e/pba1.html

An Introduction to Modern Econometrics Using Stata:

http://www.stata-press.com/books/imeus.html

On Mar 23, 2008, at 02:33 , statalist-digest wrote:

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?

* * 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/

- Prev by Date:
**Re: st: linear and cubic spine regression** - Next by Date:
**Re: st: Remove column headers in -estout-** - Previous by thread:
**st: Remove column headers in -estout-** - Next by thread:
**st: re: linear and cubic spline regression** - Index(es):

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