help for vallabframe(Roger Newson)

Convert a list of value labels to variables in a new data frame

vallabframe [ namelist ] , frame(framename[,replace change])

[ namevar(newvarname) valuevar(newvarname) labelvar(newvarname) ]

where namelist is a list of names, assumed to belong to value labels,
and set to the list of all value labels in the current data frame
if not specified.

Description

The vallabframe package inputs a list of value label names,
and outputs a new data frame,
containing a dataset with 1 observation per value label per value,
and data on the label specified by the value label for the value.
This dataset may then be listed, stored,
or exported to a generic (or proprietary) format
of the user's choice.

Options for vallabframe

frame( name, [ replace change ] ) is compulsory.
It specifies an output data frame,
to be generated to contain the output data set,
which will have 1 observation per value label per value,
and data on the label specified by the value label for the value.
The dataset will have 3 variables,
containing, respectively, the value label name, the value, and the label,
with names specified by the options namevar(), valuevar() and labelvar(),
respectively.
It will be sorted primarily by the namevar() variable,
and secondarily by the valuevar() variable.
If replace is specified, then any existing data frame of the same name is overwritten.
If change is specified,
then the current data frame will be changed to the output data frame
after the execution of vallabframe.
The frame() option may not specify the current data frame.

namevar(newvarname) specifies the name of the variable in the output data frame
containing the value label names.
It is set to name if not specified.

valuevar(newvarname) specifies the name of the variable in the output data frame
containing the values.
It is set to value if not specified.

labelvar(newvarname) specifies the name of the variable in the output data frame
containing the label specified by the value label for the value.
It is set to value if not specified.

Remarks

The vallabframe package is an inverse of the SSC packege varlabdef,
which converts from a list of 3 variables in the current data frame,
specifying value label names, values and labels, respectively,
to a list of value labels.
vallabframe is especially useful if the input value labels
have been created using the official Stata encode command,
or the SSC package sencode.
It is also especially useful
if the user wants to export the value labels from the output frame
to a non-Stata format.
For instance, we can use export delimited to export them to a generic worksheet,
or export excel to export them to a proprietary Microsoft Excel worksheet.

Examples

The following examples use the SSC package xauto,
which creates an extemded version of the auto data distributed with official Stata,
with multiple value labels.

Set-up:

. xauto, clear

. describe, full

Simple example:

. vallabframe, frame(frankie, replace)

. frame frankie: list, abbr(32) sepby(name)

Complicated example:

. vallabframe odd us, frame(frieda, replace) name(nana) value(valerie) label(lana)

. frame frieda: list, abbr(32) sepby(nana)

Drop created frames:

. capture noisily frame drop frankie

. capture noisily frame drop frieda

Author

Roger Newson, Queen Mary University London, UK.

Email: r.newson@qmul.ac.uk

Also see

Manual: [D] label, [D] encode,
[D] export, [D] export delimited, [D] export excel, [P] capture

On-line: help for label, export, export delimited, export excel, capture

help for sencode, vallabdef if installed