Statalist The Stata Listserver


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

Re: st: How to assign value labels to several variables at once?


From   "Neil Shephard" <[email protected]>
To   [email protected]
Subject   Re: st: How to assign value labels to several variables at once?
Date   Mon, 12 Jun 2006 10:26:52 +0800

On 6/12/06, buddyb <[email protected]> wrote:
Hey Joseph,
Here is what I entered:
for each var of varlist q13brep q13crep q13drep
q13erep q13frep q13grep q13hrep q13irep q13jrep
q13krep q13lrep q13mrep (enter)

and I get an invalid syntax...

for each  will return invalid syntax since the command is -foreach-
without a space.  You are also missing an opening bracket '{'.  See
-help foreach- for correct usage.

I have tried this:

local vars " q13brep q13crep q13drep q13erep q13frep
q13grep q13hrep q13irep q13jrep q13krep q13lrep
q13mrep"

foreach v of local var {

label values ???? replabel

}

Two problems with the above, firstly since var is a local macro it
needs to be put in single quotes `var' (note that the first single
quote is usually located to the left of the 1 key on most english
keyboards).

Secondly ???? should be v again in single quotes.

Joseph's examples works fine if the syntax is followed (whilst
substituting in your variable list and your chosen labelname).

Refer to the help pages for -foreach- and -local- for further
clarification.  There are also useful  sections in the User and
Programming manuals (although I don't have copies of either to hand so
can't advise which sections).

Neil
--
"After one look at this planet any visitor from outer space would say
"I want to see the manager." - William S. Burroughs

()  ascii ribbon campaign - against html mail
/\                        - against microsoft attachments
(www.gnu.org/philosophy/no-word-attachments.html)

Email - [email protected] / [email protected]
Website - http://slack.ser.man.ac.uk/
*
*   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