Statalist The Stata Listserver


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

RE: st: String vector


From   "Hendri Adriaens" <[email protected]>
To   <[email protected]>
Subject   RE: st: String vector
Date   Sat, 28 Apr 2007 10:56:20 +0200

> -foreach- allows you to loop over a varlist. varlists allow many
> shortcuts for specifying a large number of variables. see -help
> foreach- and -help varlist-. 
> 
> If you wanted to store the variable names, you typically would not do
> that in a vector but in a local. However, unless you are writing a
> general use program, you would typically not need to do that.

I don't think varlist will help me. I need the name of the variable, because
I want to do something with it. That's why I hoped to be able to make string
arrays. Say that I would want to do (in some pseudo code):

v=("a","b","c")
foreach name in v {
  gen `name'2=2*`name'
  gen `name'3=3*`name'
}

How would I do something like that?

Thanks already, best regards,
-Hendri.


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