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

Re: st: how to extract labels


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: how to extract labels
Date   Wed, 6 Nov 2002 08:59:00 +0000

Radu Ban  wrote
> thanks to those who replied to my previos queries. i obtained what i
> needed. however there's one more thing i need to do.
>
> i have an abbreviated varlist stored in a local:
>
> local outcomes "an_abbreviated_varlist"
>
> i would like to create a new variable that contains the labels of the
> variables in the abbreviated varlist (they are all labelled, the variables
> themselves, not the values) . but i cannot figure out how to extract the
> label names.

The extended macro function -variable label- is your friend. Something like 
the following might work:

gen str1 labelvar = ""                 /* <- generate an empty string var */
local i 1                              
foreach var of varlist `outcomes' {
	local lab: variable label `var'  /* <- save variable label in local `lab'
        replace labelvar = "`lab'" in `i'  /* <- store contents of `lab' in */
        local i 1
}


regards
uli

-- 
[email protected]
http://www.sowi.uni-mannheim.de/lesas

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