encode¶
Convert a string variable into a new integer-coded variable (1..K for sorted unique nonmissing values), create a matching value-label set, and attach it.
When to use
Turn string categories into numeric codes with value labels for tabulate and modeling.
Syntax¶
Options¶
generate(<newvar>): Required. Name of the new integer variable to create.label(<lblname>): Optional. Name of the value-label set to create (defaults to<newvar>).