[U] 12.4 Strings
A string is a sequence of characters and is typically enclosed in double
quotes. The quotes are not considered a part of the string but delimit
the beginning and end of the string. The following are examples of valid
All the strings above are distinct. Capitalization matters. Leading and
trailing spaces matter. Also note that "1.2" is a string and not a
number because it is enclosed in quotes.
There is never a circumstance in which a string cannot be delimited with
quotes, but there are instances where strings do not have to be delimited
by quotes, such as when inputting data. In those cases, nondelimited
strings are stripped of their leading and trailing blanks. Delimited
strings are always accepted as is.
The special string "", often called null string, is considered by Stata
to be a missing. No special meaning is given to the string containing
one period, ".".
In addition to double quotes for enclosing strings, Stata also allows
compound double quotes: `" and "'. You can type "string" or you can
type `"string"', although users seldom type `"string"'. Compound double
quotes are of special interest to programmers because they nest and
provide a way for a quoted string to itself contain double quotes (either
simple or compound). See [U] 18.3.5 Double quotes.
Stata provides two types of strings: str#s and strLs. str#s are
fixed-length string storage types. A str36 string can hold 36
characters. Stata allows str1, str2, str3, ..., str2045. strLs are
Stata's long strings, which can be up to 2-billion characters long.
strLs can hold binary strings, whereas str#s can only hold text
characters. See [U] 12.4.7 str1--str2045 and str and [U] 12.4.8 strL for
more information. If your strings contain Unicode characters, see [U]
12.4.2 Handling Unicode strings.