help labellist
-------------------------------------------------------------------------------

Title

labellist -- List value labels and more

Syntax

labellist [namelist] [, labels nomissing rc0 returnall ]

where namelist is a varlist, a list of value label names, or a combination of the two

Description

labellist lists value label names, values and corresponding labels. This information is returned in r(). For variables, the variable label, if any, is also returned. If namelist is not specified it defaults to _all, meaning all variables in the dataset. Any variables in namelist that do not have a value label attached and any empty value labels are ignored. If value labels in namelist are also names of variables in the datatset, they are interpreted as such.

Options

labels specifies that _all in namelist be interpreted as all value labels in memory.

nomissing excludes (extended) missing values in value labels.

rc0 prevents labellist from stopping if one of the results cannot be returned in r(), because varname or lblname is too long. Long names will be abbreviated. The limit for variable names is 23 characters, for value label names it is 25 characters.

returnall returns the value label names, values and labels for all variables in namelist in r(varname_labels/values/lblname). If more than one variable is specified, returnall is implied. This option is retained from an older version of the program and is seldom used.

Example

. sysuse nlsw88 . labellist race married . return list . labellist race marlbl . return list

Saved results

labellist saves the following in r():

Scalars r(lblname_min) minimum nonmissing value r(lblname_max) maximum nonmissing value r(lblname_nemiss) number of extended missing values r(lblname_k) number of mapped values, including missing

For variables

Macros r([varname_]labels) labels r([varname_]values) values r([varname_]lblname) value label name r([varname_]varlabel) variable label

If only one variable is specified (additionally)

Macros r(_labels) labels r(_values) values r(_lblname) value label name r(_varlabel) variable label

For value labels

Macros r(lblname_labels) labels r(lblname_values) values r(lblnamelist) list of specified value label names

Acknowledgments

The concept is borrowed from Ben Jann's labelsof.

The approach taken is inspired by Austin Nichols, who also encouraged me to make myself familiar with Mata.

The name labellist is borrowed from official Stata's label list, as is the output.

Timea Partos suggested option nomissing.

Author

Daniel Klein, University of Bamberg, klein.daniel.81@gmail.com

Also see

Online: label

if installed: labelsof, lablist, labutil2