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: How do I put a value of a local macro into a variable label
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: How do I put a value of a local macro into a variable label
Date
Fri, 27 Jan 2012 13:10:43 +0000
At a guess what you want to is associate 1 2 3 4 with a b c d
respectively. There are several ways to do this. Here is one.
tokenize "1 2 3 4"
local i = 1
foreach w in a b c d {
label var `w'var "Variable of wave ``i'' "
local ++i
}
Your example would permit simpler solutions because the values are
just 1 2 3 4, but I've given a more general technique.
There is a more complete discussion including other solutions in
http://www.stata-journal.com/article.html?article=pr0009
which is accessible to anyone regardless of being a subscriber to the
Stata Journal.
Nick
On Fri, Jan 27, 2012 at 12:36 PM, Andreas Daniel
<[email protected]> wrote:
> is there a way to put the values of a local macro into a variable label
> using a foreach loop, like
>
>
> local wave 1 2 3 4
>
> foreach w in a b c d {
>
> label var `w'var "Variable of wave `wave' "
>
> }
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/