Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How can I obtain the name of a variable's value label programatically?


From   "K Jensen" <k.x.jensen@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How can I obtain the name of a variable's value label programatically?
Date   Wed, 20 Feb 2008 14:22:36 +0000

On 20/02/2008, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> --- K. Jensen wrote:
> > I would like to obtain the name of a variable's value label
> > programatically within  a loop.
>
> You can do that using extended macro function, see:
>  -help extended_fcn- and the example below:
>
>  *------------ begin example ---------------
>  sysuse auto, clear
>  foreach var of varlist _all {
>         local lab : value label `var'
>         di "`lab'"
>  }
>  *------------ end example -----------------

Thanks Martin. You're wonderful!
I hate to say but I forgot to ask my follow up question:-
How could I put the values and labels of a specific value label into a
local macro

i.e. for the auto data
. label list origin
origin:
           0 Domestic
           1 Foreign

two lists containing (0,1) and ("Domestic", "Foreign")

Thankyou yet again
Karin
*
*   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