*! version 1.2.0 02jun2011

Title

encodefrom -- Encode variable with values and value labels
specified in an external crosswalk.

Table of contents

Syntax
Description
Options
Examples
Author
Remarks

Syntax

encodefrom varname using filename
, filetype(string) raw(string) clean(string) label(string)
[options]

Main

raw(string) column in external crosswalk that contains values of varname to be encoded

clean(string) column in external crosswalk that contains clean numeric values of varname

label(string) column in external crosswalk that contains clean value labels

Crosswalk

filetype(excel|delimited|stata) file type of external crosswalk

sheet(string) sheet name if the external crosswalk is an Excel workbook

delimiters("chars") chars used as delimiters in the external crosswalk;
by default, "\t" or ","

Other

label_name(string) name of value label; defaults to varname

noallow_missing prohibits mapping non-missing raw values to missing clean values

caseignore ignores capitalization when matching values of varname with
raw values in external crosswalk

Description

encodefrom encodes varname using the values and labels stored in an
external crosswalk. Storing the mapping from raw values to clean values in a crosswalk
helps users align codes across data sets.

Options

Main

raw(string) specifies the crosswalk column that contains the values of varname in memory.

clean(string) specifies the crosswalk column that contains clean numeric values of varname.
By default, this column can include missing values. To refuse using files that map non-missing raw values to missing clean values, use the noallow_missing option.

label(string) specifies the crosswalk column that contains clean value labels.

Crosswalk

filetype(excel|delimited|stata) specifies the file type
of the crosswalk.
The excel option is for Excel workbooks with file extensions .xls
and .xlsx. The delimited option supports .csv and other
character-delimited text files. The stata option is for Stata .dta files.

sheet(string) specifies a sheet name for the crosswalk in an Excel workbook.
This option can only be used with filetype(excel). In keeping with the syntax for import excel, the
program defaults to using the workbook's first sheet if no sheet is specified.

delimiters("chars") specifies the delimiter that separates columns in the crosswalk.
This option can only be used with filetype(delimited). For .csv crosswalks
the syntax is delimiters(","). For tab-delimited crosswalks the syntax is delimiters("\t"). In keeping with the syntax for import delimited,
if no delimiter is specified, Stata will check if the file is delimited by tabs or commas by default.

Other

label_name(string) specifies a name for the clean value label. If no name is
specified, the default label name is the variable name.

noallow_missing prohibits mapping non-missing raw values to missing clean values.

caseignore ignores capitalization when matching values of varname with
raw values in external crosswalk.

Examples

. encodefrom var1 using codes.xlsx, filetype(excel) raw(old_values) clean(new_values) label(label)

. encodefrom var1 using codes.csv, filetype(delimited) delimiters(",") raw(old_values) clean(new_values) label(label)

Author

Sally Hudson

E-mail: sally.hudson@virginia.edu

GitHub: https://github.com/slhudson

Remarks

This program was developed through work at the School Effectiveness and
Inequality Initative at MIT. Thanks are due to the many SEII research
assistants who used and refined it over the years, especially Tyler Hoppenfeld,
Sookyo Jeong, and Alicia Weng. If you encounter any bugs or have suggestions
for additional features, please feel free to submit a pull request on GitHub.
The GitHub repository also contains more examples of this program in use.