Thanks to Kit Baum, a new suite of commands, elabel, is now available from the SSC.
The elabel commands are not designed to solve specific problems; they extend Stata's native label commands in a general way to facilitate the everyday data management tasks.
For example, elabel allows wildcard characters in value label names
elabel also allows you to refer to value label names via variable names they are attached to
and, sometimes, returns additional results. For example, the list subcommand returns the integer values and associated text in value labels
The extensions that elabel brings apply equally to other label (sub)commands. You can easily modify multiple value labels at a time.
There are many other commands, some community-contributed some official Stata, that modify value labels systematically. For example, the numlabel command prefixes values to value labels. Although less convenient, elabel can do the same
You can modify variable labels with elabel in the same way. You can, for example, convert all words in variable labels to start with a capital letter.
While many tasks that elabel performs are easily done with other commands, there are some features rather unique to elabel. For example, elabel has a recode subcommand that is useful when you want to recode variables and keep the value labels. Here, we reverse the values in variable race and the respective value label
Another unique feature is elabel's rename subcommand. Much like Stata's rename command for variables, elabel can change value label names in a systematic way.
The above examples should give you the general idea. For more details see the help files. I hope some of you will find these commands useful.
Best
Daniel
The elabel commands are not designed to solve specific problems; they extend Stata's native label commands in a general way to facilitate the everyday data management tasks.
For example, elabel allows wildcard characters in value label names
Code:
. sysuse nlsw88 (NLSW, 1988 extract) . elabel list *r* racelbl: 1 white 2 black 3 other marlbl: 0 single 1 married gradlbl: 0 not college grad 1 college grad
Code:
. elabel list (married) marlbl: 0 single 1 married
Code:
. return list scalars: r(min) = 0 r(max) = 1 r(hasemiss) = 0 r(nemiss) = 0 r(k) = 2 macros: r(name) : "marlbl" r(values) : "0 1" r(labels) : ""single" "married""
Code:
. elabel define *r* .a "don`t know" .b "refused" , add . elabel list *r* gradlbl: 0 not college grad 1 college grad .a don`t know .b refused marlbl: 0 single 1 married .a don`t know .b refused racelbl: 1 white 2 black 3 other .a don`t know .b refused
Code:
. elabel define *r* (= #) (= strofreal(#)+". "+@) , modify . elabel list *r* racelbl: 1 1. white 2 2. black 3 3. other .a .a. don`t know .b .b. refused marlbl: 0 0. single 1 1. married .a .a. don`t know .b .b. refused gradlbl: 0 0. not college grad 1 1. college grad .a .a. don`t know .b .b. refused
Code:
. describe race married collgrad storage display value variable name type format label variable label ----------------------------------------------------------------------------- race byte %14.0g racelbl race married byte %14.0g marlbl married collgrad byte %19.0g gradlbl college graduate . elabel variable (race married collgrad) (= strproper(@)) . describe race married collgrad storage display value variable name type format label variable label ----------------------------------------------------------------------------- race byte %14.0g racelbl Race married byte %14.0g marlbl Married collgrad byte %19.0g gradlbl College Graduate
Code:
. tabulate race Race | Freq. Percent Cum. ------------+----------------------------------- white | 1,637 72.89 72.89 black | 583 25.96 98.84 other | 26 1.16 100.00 ------------+----------------------------------- Total | 2,246 100.00 . elabel recode racelbl (1/3=3/1) . return list macros: r(rules) : "(1=3) (2=2) (3=1)" . recode race `r(rules)' (race: 1663 changes made) . tabulate race Race | Freq. Percent Cum. ------------+----------------------------------- other | 26 1.16 1.16 black | 583 25.96 27.11 white | 1,637 72.89 100.00 ------------+----------------------------------- Total | 2,246 100.00
Code:
. elabel dir racelbl marlbl gradlbl occlbl indlbl smsalbl unionlbl . elabel rename (*lbl) (*_vl) . elabel dir union_vl smsa_vl race_vl occ_vl mar_vl ind_vl grad_vl
Best
Daniel