Hi everyone, the title says it all. Thanks, too, for
the 'foreach' explanation...it has saved me HOURS of
work.
Buddy
--- Thuy Le <tl6775a@american.edu> wrote:
> Hi,
>
> You cannot "save" the label interactively. You have
> to put them in your
> do-file. If they are a long list, use #delimit
> (check help if you didn't
> know it). An example I use to lable province codes
> with province names for
> Vietnam:
>
> # delimit ;
> label define prov_lab
> 101 "Ha Noi"
> 103 "Hai Phong"
> 105 "Ha Tay"
> 107 "Hai Duong"
> 109 "Hung Yen"
> 111 "Ha Nam"
> 113 "Nam Dinh"
> 115 "Thai Binh"
> 117 "Ninh Binh"
> 201 "Ha Giang"
> 203 "Cao Bang" ;
>
> #delimit cr
> label values prov_id prov_lab
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On
> Behalf Of buddyb
> Sent: Sunday, June 11, 2006 11:25 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: How to assign value labels to
> several variables at once? -
> new problem
>
> HI everyone, and thanks for your help.
>
> I got the foreach command to work - and everything
> is great....but now...my
> label stop showing up...I'm thinking I'm limited to
> how large my label
> database can be or something? I don't know - I've
> been saving my work like
> mad, so it's not that I didn't save it - my label
> for the last part of my
> databased just aren't appearing??
>
> Any ideas?
>
> Buddy
>
> --- Joseph Coveney <jcoveney@bigplanet.com> wrote:
>
> > Buddy wrote:
> >
> > 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.
> >
> >
>
----------------------------------------------------------------------------
> ----
> >
> > Again, as Neil mentioned, the *for* and *each* are
> combined into one
> > word, *foreach*.
> >
> > It's difficult to tell from what you've shown why
> your variables are
> > not labeled in the second example. Be sure that
> the label EXPlabel
> > contains labels corresponding to the values
> present in the dataset.
> > If there is no correspondence, then there won't be
> any labeling.
> >
> > Follow the example below, which mimics your second
> example, in order
> > to see where things might have gone awry. I
> haven't shown it, but
> > wildcards are permitted in the varlist, so that
> >
> > foreach var of varlist q33* {
> >
> > may be substituted for the loop's opening line, if
> none of the names
> > of the variables that you do not desire to apply
> value labels to begin
> > with the stub.
> >
> > Joseph Coveney
> >
> > . clear
> >
> > . set more off
> >
> > . set seed `=date("2006-06-12", "ymd")'
> >
> > . set obs 3
> > obs was 0, now 3
> >
> > . local variable_list q33cmplx q33time q33satis
> >
> > . foreach var of local variable_list {
> > 2. generate byte `var' = floor(uniform() *
> 4)
> > 3. replace `var' = .m if !`var'
> > 4. }
> > (0 real changes made)
> > (0 real changes made)
> > (1 real change made, 1 to missing)
> >
> > . list, noobs
> >
> > +-------------------------------+
> > | q33cmplx q33time q33satis |
> > |-------------------------------|
> > | 1 1 .m |
> > | 2 1 1 |
> > | 3 2 3 |
> > +-------------------------------+
> >
> > . *
> > . * Begin here
> > . *
> > . label define EXPlabel 1 One 2 Two 3 Three .m
> Missing
> >
> > . local variable_list " q33cmplx q33time q33satis"
> >
> > . foreach var of local variable_list {
> > 2. label values `var' EXPlabel
> > 3. }
> >
> > . list, noobs
> >
> > +-------------------------------+
> > | q33cmplx q33time q33satis |
> > |-------------------------------|
> > | One One Missing |
> > | Two One One |
> > | Three Two Three |
> > +-------------------------------+
> >
> >
> > *
> > * 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/
>
__________________________________________________
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/