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   buddyb <buddyb_99@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to assign value labels to several variables at once?
Date   Sun, 11 Jun 2006 18:53:50 -0700 (PDT)

Hey Joseph,

Thanks for your help, but it is still not working:

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...

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

}

and I can't seem to figure out what to put in ???? -
I've tried var, I've tried v, I've tried all of the
variables in quotes again?

Any advice?

Thanks,
Buddy

--- Joseph Coveney <jcoveney@bigplanet.com> wrote:

> Buddy wrote:
> 
> I'm crossing over from SAS, so am having problems
> with
> some elementary procedures, so appreciate your
> patience.
> 
> I'm using STATA 8.
> 
> I understand how to assign one variable to one value
> label
> (i.e. label values variablename labelname)
> 
> I'm wondering how to assign several variables to the
> same label name?
> 
> I.e. label values variable1 variable 2 labelname?
> 
>
--------------------------------------------------------------------------------
> 
> Stata's help files and user's manuals will indicate
> that the command can
> take a list of variables by displaying the command's
> argument as *varlist*
> in the syntax diagram.  If the command can take on
> only a single variable,
> it will say *variable*.  The help file indicates
> that -label values- takes
> on only a single variable.
> 
> You can, nevertheless, easily label values of a list
> of variables by using
> a -foreach- loop; it's three lines of code,
> including braces.
> 
> Joseph Coveney
> 
> 
> foreach var of varlist variable1 variable 2 {
>     label values `var' labelname
> }
> 
> *
> *   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index