Stata 15 help for char

[P] char -- Characteristics

Syntax

Define characteristics

char [define] evarname[charname] [["]text["]]

List characteristics

char list [ evarname[[charname]] ]

Rename characteristics

char rename oldvar newvar [, replace ]

Also related is

{local | global} mname : char evarname[[charname]]

evarname is a variable name or _dta and charname is a characteristic name. In the syntax diagrams, distinguish carefully between [], which you type, and [], which indicate the element is optional.

Description

The dataset itself and each variable within the dataset have associated with them a set of characteristics. Characteristics are named and referred to as varname[charname], where varname is the name of a variable or _dta. The characteristics contain text. Characteristics are stored with the dataset in the Stata-format .dta dataset, so they are recalled whenever the dataset is loaded.

Characteristics are sometimes used in Stata programs to store additional metadata for variables. See [U] 12.8 Characteristics for more details.

Option

replace (for use only with char rename) specifies that if characteristics of the same name already exist, they are to be replaced. replace is a seldom-used, low-level, programmer's option.

char rename oldvar newvar moves all characteristics of oldvar to newvar, leaving oldvar with none and newvar with all the characteristics oldvar previously had. char rename oldvar newvar moves the characteristics, but only if newvar has no characteristics with the same name. Otherwise, char rename produces the error message that newvar[whatever] already exists.

Examples

Setup . sysuse auto

Define characteristic one attached to the data . char _dta[one] this is char named one of _dta

Define characteristic two attached to the data . char _dta[two] this is char named two of _dta

List the characteristics . char list

Clear characteristic two attached to the data . char _dta[two]

List the characteristics . char list

Define characteristic one attached to variable mpg . char mpg[one] this is char named one of mpg

Define characteristic two attached to variable mpg . char mpg[two] this is char named two of mpg

List all the characteristics . char list

List the characteristics attached to variable mpg . char list mpg[]

Move the characteristics attached to variable mpg to variable price . char rename mpg price

List the characteristics attached to variable price . char list price[]


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