Hi,
You should check the foreach command again. Suppose you have defined the
label as EXPlabel, here is the program code that you need to copy and paste
into your do-file editor, save it and run from there:
local vars q33cmplx q33time q33satis
foreach v of local vars {
label values `v' EXPlabel
}
Thuy
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of buddyb
Sent: Sunday, June 11, 2006 10:45 PM
To: [email protected]
Subject: Re: st: How to assign value labels to several variables at once?
Hi Neil, and thanks for your help...Using Joseph's syntax....
. for each var of varlist q33cmplx q33time q33satis { I get incorrect
syntax....
invalid syntax
r(198);
Using the other example:
. local vars " q33cmplx q33time q33satis"
. foreach v of local var {
2. label values `v' EXPlabel
3. }
I don't get an error message, but my values are not labeled. I am checking
the programming, user's guide, etc....but there is not an example of
labeling multiple variables with the same value.
Anyways, any help you can offer is appreciated.
Thanks,
Buddy
--- Neil Shephard <[email protected]> wrote:
> 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/
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
* 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/
*
* 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/