Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Problem with temporary variable and macro suffix
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Problem with temporary variable and macro suffix
Date
Thu, 29 Aug 2013 17:29:00 +0100
Works for me (in Stata 10.1)
Not quite documented, but temporary variables (used to) have names
beginning with __ and followed by 6 characters assigned by Stata, so
that you can (could) add suffixes in practice, although somewhere
Stata says that you shouldn't assume that you can do that.
That aside, this is idiomatic
foreach a in element1 element2 element3 {
tempvar this
gen `this' = .
local all `all' `this'
}
followed typically by loops over `all'.
Nick
[email protected]
On 29 August 2013 17:21, Thomas Lux <[email protected]> wrote:
> I have a little problem with temporary variables in my program.
>
> I want to create temporary variables with some foreach-elements as a suffix.
> I did:
>
> foreach a in element1 element2 element3 {
> tempvar new`a'
> gen `new`a'' = .
> }
>
> But this does not work.
> I there any other way to do it?
>
>
> Best,
> Thomas
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/