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 <[email protected]> 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/