varname (from [U] 11.4 varname and varlists)
A varname is one variable name, such as
When we use the term varname, we usually mean an existing varname -- a
variable that already exists in the dataset. The alternative would be a
When referring to an existing varname, we can abbreviate -- use only some
of the leading characters -- as long as we specify enough to uniquely
identify the variable:
Myv might be a unique abbreviation for Myvar.
reciprocal might be a unique abbreviation for
Sometimes we can use the full varlist notation, but it must identify one
my*r might uniquely identify myvar
r*gallon might uniquely identify reciprocal_of_miles_per_gallon.
In the varlist notation, * means that zero or more characters go here.
Varnames are often specified inside options, and then sometimes the
varlist notation is allowed and sometimes it is not. Abbreviations are
always allowed, however, assuming that you have not turned them off; see
Note that variable names may be 1 to 32 Unicode characters long and must
start with a Unicode letter or _, and the remaining characters may be
Unicode letters, _, or Unicode number digits. Examples of Unicode
letters are "a", "Z", and "é"; examples of Unicode digits are 0, 1, and
The formal definition of a Unicode letter is a Unicode character for
which uisletter() returns 1. A Unicode digit is a Unicode character for
which uisdigit() returns 1.
An invalid UTF-8 sequence is allowed in the variable name and is counted
as one character. This is mainly for backward compatibility reasons.
For example, capital letter "E" with a grave accent is encoded as
char(200) in ISO-Latin-1 encoding, which may appear in variable names of
older versions of Stata, but char(200) alone is an invalid UTF-8
sequence. See [U] 184.108.40.206 Advice for users of Stata 13 and earlier for
. sysuse auto
. list gear_ratio in 1/10
. generate weightSquared = weight^2
. list we* in 1/10
. format weightS %12.0gc
. rename rep78 repair_record_of_cars_in_1978
. describe rep, fullnames