Stata Packages for Research

rencode

Encode string variables in place

Data Management

Installation

net install rencode, from("https://raw.githubusercontent.com/bbdaniels/stata/main/")

Description

rencode encodes string variables and replaces them with the encoded numeric version, preserving the variable name.

Syntax

rencode string_varlist

Example

* Standard encode requires a new variable name
encode mystring, gen(mystring_num)

* rencode replaces in place
rencode mystring
* mystring is now numeric with value labels

Author

Benjamin Daniels (bbdaniels@gmail.com)