Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: -levels- question


From   "Danielle H. Ferry" <[email protected]>
To   StataList <[email protected]>
Subject   Re: st: Re: -levels- question
Date   Thu, 18 Sep 2003 13:53:42 -0400

Thank you, Nick & Roger! I can see that Nick's & Roger's answers are
essentially the same. One more (macro) question: Why isn't it necessary in
Roger's solution to put a space between _fvalcur_ and _:label (mpg)_ ?

-Danielle

On 9/18/03 1:27 PM, "Roger Newson" <[email protected]> wrote:

> At 13:06 18/09/03 -0400, Danielle H. Ferry wrote:
>> Hi there,
>> 
>> Using the example provided in the documentation of -levels-:
>> 
>>     . levels factor, local(levels)
>>     . foreach l of local levels {
>>     .        di "-> factor = `l'"
>>     .        whatever if factor == `l'
>>     . }
>> 
>> Is it possible to display the value labels of factor rather than the
>> numerical codes?
> 
> Yes. Use the extended macro function -label- (see online help for -macro-
> or -[P] macro-).
> 
> For instance, instead of
> 
> di "-> factor = `l'"
> 
> you could have typed
> 
> local fvalcur:label (factor) `l'
> di "-> factor = `fvalcur'"
> 
> I hope this helps.
> 
> Roger
*
*   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