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
Andreas Daniel <[email protected]>
To
[email protected]
Subject
Re: st: How do I put a value of a local macro into a variable label
Date
Mon, 30 Jan 2012 09:02:08 +0100
Dear Christophe, dear Nick,
thank you for your help, especially for the literature reference!!
Andy
Am 27.01.2012 14:10, schrieb Nick Cox:
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/
--
Dipl. Soz. Andreas Daniel
Project "Crime in the modern city"
University of Bielefeld
Faculty of Sociology
Universitätsstraße 25
D-33615 Bielefeld
Room: U4-115
http://www.crimoc.org
Telephone: +49 (0) 521-106 3849
E-Mail: [email protected]
*
* 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/