Code:
ssc install elabel , replace
I have first announced elabel here, where I have also shown some examples. In this post, I will show examples of three new features of elabel.
One of the new features of elabel borrows from a sometimes overlooked syntax element of new variable lists that is used with, e.g., generate:
Code:
generate newvar:lblname =exp
Code:
. sysuse nlsw88 , clear
(NLSW, 1988 extract)
. describe south-c_city
storage display value
variable name type format label variable label
------------------------------------------------------------------------------
south byte %8.0g lives in south
smsa byte %9.0g smsalbl lives in SMSA
c_city byte %8.0g lives in central city
. elabel define (south-c_city):yesno 0 "no" 1 "yes"
. describe south-c_city
storage display value
variable name type format label variable label
------------------------------------------------------------------------------
south byte %8.0g yesno lives in south
smsa byte %9.0g yesno lives in SMSA
c_city byte %8.0g yesno lives in central city
. label list yesno
yesno:
0 no
1 yes
Suppose, I later decide that I want each variable to have its own value label attached. A second feature of elabel borrows from egen's syntax and allows (pseudo-) functions to define (or modify) value labels. I will use a (pseudo-)function to make multiple copies of the value label yesno using the names of the variables that have yesno attached. To get a list of all variables that have a value label yesno attached, I will use ds
Code:
. ds , has(vallabel yesno)
south smsa c_city
. local varlist `r(varlist)'
. elabel define `varlist' = copy(yesno)
. label list `varlist'
south:
0 no
1 yes
smsa:
0 no
1 yes
c_city:
0 no
1 yes
Code:
. elabel values (`varlist') (`varlist')
. describe south-c_city
storage display value
variable name type format label variable label
------------------------------------------------------------------------------
south byte %8.0g south lives in south
smsa byte %9.0g smsa lives in SMSA
c_city byte %8.0g c_city lives in central city
Best
Daniel
0 Response to -elabel- updated on SSC
Post a Comment