Stata 11 help for labelbook

help labelbook dialogs: labelbook numlabel uselabel -------------------------------------------------------------------------------

Title

[D] labelbook -- Label utilities

Syntax

Produce a codebook describing value labels

labelbook [lblname-list] [, labelbook_options]

Prefix numeric values to value labels

numlabel [lblname-list], {add|remove} [numlabel_options]

Make dataset containing value-label information

uselabel [lblname-list] [using filename] [, clear var]

labelbook_options description ------------------------------------------------------------------------- alpha alphabetize label mappings length(#) check if value labels are unique to length #; default is length(12) list(#) list maximum of # mappings; default is list(32000) problems describe potential problems in a summary report detail do not suppress detailed report on variables or value labels -------------------------------------------------------------------------

numlabel_options description ------------------------------------------------------------------------- *add prefix numeric values to value labels *remove remove numeric values from value labels mask(str) mask for formatting numeric labels; default mask is "#." force force adding or removing of numeric labels detail provide details about value labels, where some labels are prefixed with numbers and others are not ------------------------------------------------------------------------- * Either add or remove must be specified.

Menu

labelbook

Data > Data utilities > Label utilities > Produce codebook of value labels

numlabel

Data > Data utilities > Label utilities > Prepend values to value labels

uselabel

Data > Data utilities > Label utilities > Create dataset from value labels

Description

labelbook displays information for the value labels specified or, if no labels are specified, all the labels in the data.

For multilingual datasets (see [D] label language), labelbook lists the variables to which value labels are attached in all defined languages.

numlabel prefixes numeric values to value labels. For example, a value mapping of 2 -> "catholic" will be changed to 2 -> "2. catholic". See option mask() for the different formats. Stata commands that display the value labels also show the associated numeric values. Prefixes are removed with the remove option.

uselabel is a programmer's command that reads the value-label information from the currently loaded dataset or from an optionally specified filename.

uselabel creates a dataset in memory that contains only that value-label information. The new dataset has four variables named label, lname, value, and trunc; is sorted by lname value; and has 1 observation per mapping. Value labels can be longer than the maximum string length in Stata; see limits. The new variable trunc contains 1 if the value label is truncated to fit in a string variable in the dataset created by uselabel.

uselabel complements label, save, which produces an ASCII file of the value labels in a format that allows easy editing of the value-label texts.

Specifying no list or _all is equivalent to specifying all value labels. Value-label names may not be abbreviated or specified with wildcards.

Options for labelbook

alpha specifies that the list of value-label mappings be sorted alphabetically on label. The default is to sort the list on value.

length(#) specifies the minimum length that labelbook checks to determine whether shortened value labels are still unique. It defaults to 12, the width used by most Stata commands. labelbook also reports whether value labels are unique at their full length.

list(#) specifies the maximum number of value-label mappings to be listed. If a value label defines more mappings, a random subset of # mappings is displayed. By default, labelbook displays all mappings. list(0) suppresses the listing of the value-label definitions.

problems specifies that a summary report be produced describing potential problems that were diagnosed:

1. Value label has gaps in mapped values (e.g., values 0 and 2 are labeled, while 1 is not) 2. Value label strings contain leading or trailing blanks 3. Value label contains duplicate labels, i.e., there are different values that map into the same string. 4. Value label contains duplicate labels at length 12 5. Value label contains numeric -> numeric mappings 6. Value label contains numeric -> null string mappings 7. Value label is not used by variables See labelbook_problems for a discussion of these problems and advice on overcoming them.

detail may be specified only with problems. It specifies that the detailed report on the variables or value labels not be suppressed.

Options for numlabel

add specifies that numeric values be prefixed to value labels. Value labels that are already numlabeled (using the same mask) are not modified.

remove specifies that numeric values be removed from the value labels. If you added numeric values by using a nondefault mask, you must specify the same mask to remove them. Value labels that are not numlabeled or are numlabeled using a different mask are not modified.

mask(str) specifies a mask for formatting the numeric labels. In the mask, # is replaced by the numeric label. The default mask is "#. " so that numeric value 3 is shown as "3. ". Spaces are relevant. For the mask "[#]", numeric value 3 would be shown as "[3]".

force specifies that adding or removing numeric labels be performed, even if some value labels are numlabeled using the mask and others are not. Here only labels that are not numlabeled will be modified.

detail specifies that details be provided about the value labels that are sometimes, but not always, numlabeled using the mask.

Options for uselabel

clear permits the dataset to be created, even if the dataset already in memory has changed since it was last saved.

var specifies that the varlists using value label vl be returned in r(vl).

Examples

--------------------------------------------------------------------------- Setup . sysuse auto . label define repair 1 "very poor" 2 "poor " 4 "good" 5 "very good"

Display information for all value labels . labelbook

Display information for value label origin . labelbook origin

Produce summary report showing problems with value label origin . labelbook origin, problems

Produce summary report showing problems with value label repair . labelbook repair, problems

Assign value label repair to variable rep78 . label values rep78 repair

Produce codebook for rep78 . codebook rep78

Modify the repair value label by removing the trailing space after "poor" and defining the label for "3" . label define repair 2 "poor" 3 "average", modify

Produce summary report showing problems with value label repair . labelbook repair, problems

Report table of frequencies for rep78 . tabulate rep78

Prefix numeric values to value labels . numlabel, add

Report table of frequencies for rep78 . tabulate rep78

Remove the prefixed numeric value labels from the repair value label . numlabel repair, remove

Report table of frequencies for rep78 . tabulate rep78

Prefix numeric values to repair value label using the specified mask . numlabel repair, add mask([#])

Report table of frequencies for rep78 . tabulate rep78

--------------------------------------------------------------------------- Setup . sysuse auto

Create a dataset containing the labels and values for value labels . uselabel

Describe the data . describe

List the data . list ---------------------------------------------------------------------------

Saved results

labelbook saves the following in r():

Macros r(names) lblname-list r(gaps) gaps in mapped values r(blanks) leading or trailing blanks r(null) name of value label containing null strings r(nuniq) duplicate labels r(nuniq_sh) duplicate labels at length 12 r(ntruniq) duplicate labels at maximum string length r(notused) not used by any of the variables r(numeric) name of value label containing mappings to numbers

uselabel saves the following in r():

Macros r(lblname) list of variables that use value label lblname (only when var option is specified)

Also see

Manual: [D] labelbook

Help: [D] codebook, [D] describe, [D] encode, [D] label, [M-3] matalabel


© Copyright 1996–2010 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index