{smcl}
{* *! version 1.1.4  29jun2011}{...}
{findalias asfrmiss}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "[D] codebook" "help codebook"}{...}
{vieweralsosee "[D] egen" "help egen"}{...}
{vieweralsosee "[D] functions" "help functions"}{...}
{vieweralsosee "[MI] intro" "help mi_intro"}{...}
{vieweralsosee "[D] mvencode" "help mvencode"}{...}
{vieweralsosee "[D] recode" "help recode"}{...}
{vieweralsosee "[XT] xtdescribe" "help xtdescribe"}{...}
{vieweralsosee "[U] 13 Functions and expressions (expressions)" "help exp"}{...}
{viewerjumpto "Description" "missing##description"}{...}
{viewerjumpto "Remarks" "missing##remarks"}{...}
{title:Title}

{pstd}
{findalias frmiss}


{marker description}{...}
{title:Description}

{pstd}
Stata has 27 numeric missing values:

{pmore}
{cmd:.}, the default, which is called the "system missing value"
or {cmd:sysmiss}

    and

{pmore}
{cmd:.a}, {cmd:.b}, {cmd:.c}, ..., {cmd:.z}, which are called the
"extended missing values".

{pstd}
Numeric missing values are represented by large positive values.
The ordering is

{center:all nonmissing numbers < {cmd:.} < {cmd:.a} < {cmd:.b} < ... < {cmd:.z}}

{pstd}
Thus, the expression {cmd:age > 60} is true if variable {cmd:age} is
greater than 60 or missing.

{pstd}
To exclude missing values, ask whether the value is less than "{cmd:.}".  For
instance,

{phang2}{cmd:. list if age > 60 & age < .}

{pstd}
To specify missing values, ask whether the value is greater than or equal to
"{cmd:.}".  For instance,

{phang2}{cmd:. list if age >=.}

{pstd}
Stata has one string missing value, which is denoted by {cmd:""} (blank).


{marker remarks}{...}
{title:Remarks}

{pstd}
More details concerning missing values and their treatment in Stata are 
provided under the following headings:

	{help missing##overview:Overview}
	{help missing##expressions:Expressions}
	{help missing##operators:Operators}
	{help missing##functions:Functions}
	{help missing##matrices:Matrices}
	{help missing##useful:Useful commands}
	{help missing##value:Value labels}
	{help missing##estimation:Estimation commands}
	{help missing##technical:Technical note:  Version 7 and earlier}


{marker overview}{...}
    {title:Overview}

{phang}
1.  Stata supports different types of numeric missing values that can be used
    to specify different reasons that a value is unknown.  The most frequently
    used missing value {cmd:.}, referred to as sysmiss, is nearly always
    generated by Stata when it cannot assign a specific value.  The 26
    extended missing values {cmd:.a}, {cmd:.b}, ..., {cmd:.z} are available to
    users requiring more elaborate tracking of missing values.

{pmore}Empty strings are treated as missing values of type string.

{phang}
2.  Numeric missing values are represented by large positive values.  This
    means that an expression such as {bind:{cmd:income > 100}} evaluates to
    {hi:true} for missing values of the variable {cmd:income}, as well as to
    those that are greater than 100.  Also, the simple expression
    {cmd:if} {it:varname} evaluates to true for all nonzero values of
    {it:varname}, including missing values.

{phang}
3.  The ordering of missing values is

{center:{it:all nonmissing numbers} < {cmd:.} < {cmd:.a} < {cmd:.b} < ... < {cmd:.z}}

{phang}
4.  Most Stata statistical commands deal with missing values by disregarding
    observations with one or more missing values (called "listwise deletion"
    or "complete cases only").


{marker expressions}{...}
    {title:Expressions}

{pstd}
Expressions occur in many places in Stata (see {manhelp syntax P} and 
{help exp}).  For example,

{phang2}
{cmd:. generate} {it:newvarname} {cmd:=} {it:exp}

{pstd}
evaluates the expression {it:exp} for each observation of the variable
{it:newvarname}.  Observations of {it:newvarname} are set to missing if
{it:exp} evaluates to missing.

{pstd}
Expressions are also used to restrict a command's operation to a subset of the
observations.  For instance,

{phang2}
{cmd:. summarize} {it:varname} {cmd:if} {it:exp}

{pstd}
summarizes {it:varname} by using all observations for which {it:exp} evaluates
to true (not zero), including observations that are missing.


{marker operators}{...}
    {title:Operators}

{pstd}
The relational operators (see {help operators}) interpret missing values
as large positive numbers (see above). All the following thus evaluate to
true

		{cmd:73 < .}        {cmd:. == .}        {cmd:.a == .a}
        	{cmd:.a != .}       {cmd:.a < .b}       {cmd:.a <= .b}

{pstd}
whereas all the following evaluate to false

		{cmd:73 >= .}       {cmd:. == .a}       {cmd:. > .a}

{pstd}
The numerical operators ({cmd:+} etc) return missing if any of their arguments
are missing.


{marker functions}{...}
    {title:Functions}

{pstd}
Stata has a few special functions for dealing with missing values:

{p 8 25 2}{cmd:missing()}{space 7}
  returns 1 (meaning true) if any of its arguments, numeric or string, evaluates
to missing and 0 (meaning false) otherwise.

{p 8 25 2}{cmd:mi()}{space 12}
  is a shorthand for {cmd:missing()}.

{p 8 25 2}{cmd:matmissing(}{it:K}{cmd:)}{space 3}
  returns 1 (meaning true) if any elements of the matrix {it:K} are missing
  and 0 (meaning false) otherwise.

{pstd}
Some Stata functions interpret {cmd:.} in a special way.  For instance,
the function {cmd:inrange(x,a,b)} returns 1 if {cmd:x} belongs in
the interval {cmd:[a,b]}.  This function interprets {cmd:a==.} as
-infinity and {cmd:b==.} as +infinity.  These special interpretations
are discussed in {help functions}.

{pstd}
Other Stata functions return missing ({cmd:.}) if one or more of the arguments
are missing or invalid.


{marker matrices}{...}
    {title:Matrices}

{pstd}
Matrices may contain all types of missing values.  The matrix operators
(see {help matrix operators})

                {cmd:-}     negate
		{cmd:'}     transpose

                {cmd:\}     row join
                {cmd:,}     column join
                {cmd:+}     add
                {cmd:-}     subtract
		{cmd:*}     multiply (including multiply by scalar)
		{cmd:/}     division by scalar
		{cmd:#}     Kronecker product

{pstd}
generate missing values elementwise.

{pstd}
In the matrix product {cmd:C=A*B}, {cmd:C}[{it:i},{it:j}] is missing if row
{it:i} of {cmd:A} or column {it:j} of {cmd:B} contain a missing value.

{pstd}
Matrix division by scalar {cmd:C=A/b} is not allowed if the scalar {cmd:b}
is a missing value.  Otherwise, missing values in matrix {cmd:A} generate
missing values in {cmd:C} elementwise.

{pstd}
Like the {helpb list} command, the {helpb matrix list} command has a
{cmd:nodotz} option to display extended missing value {cmd:.z} as a blank
string rather than as "{cmd:.z}".


{marker useful}{...}
    {title:Useful commands}

{p2colset 5 25 27 2}{...}
{p2line}
{p2col:{helpb mvencode}}changes missing values into numeric values{p_end}
{p2col:{helpb mvdecode}}changes numeric values into missing values{p_end}
{p2col:{helpb codebook}}provides extensive information about variables,
	including the occurrence of simple and extended missing values{p_end}
{p2col:{helpb misstable}}tabulates missing values{p_end}
{p2col:{helpb egen:egen, rownonmiss()}}number of valid observations in a
	varlist{p_end}
{p2col:{helpb egen:egen, rowmiss()}}number of missing values in a varlist{p_end}
{p2col:{helpb recode}}recodes a variable, optionally into a new variable, with
	special facilities to recode missing values.{p_end}
{p2col:{helpb mi}}multiple imputation of missing values{p_end}
{p2col:{helpb xtdescribe}}describes participation patterns in panel data{p_end}
{p2line}
{p2colreset}{...}


{marker value}{...}
    {title:Value labels}

{pstd}
It is possible to define value labels for the extended missing values
{cmd:.a} to {cmd:.z}, but not for sysmiss {cmd:.}.  These value labels
show up in the same way as value labels for nonmissing values.  See
{manhelp label D}.


{marker estimation}{...}
    {title:Estimation commands}

{pstd}
Most Stata commands ignore observations that are missing in one or more
of the variables referred to in the command.  For instance, the regression
command {helpb regress} disregards all observations that have a missing value
for the dependent variable or missing values for any of the independent
variables.  This method is known as "listwise deletion", "complete cases
only", etc.  It is statistically appropriate only if the missing values
are "at random".  In an {help if} or {help weight} expression to a command,
the expressions will be evaluated, and the missing values will be
processed using the operators and function() logic.

{pstd}
Stata commands that can treat multiple observations as being related to
one observational unit (for example, observations from a panel in {help xt}
models, episodes in {help st} models) ignore specific observations
from the "group", namely, those that have missing values.


{marker technical}{...}
    {title:Technical note:  Version 7 and earlier}

{pstd}
Before Stata 8, Stata had only one missing value, the period ({cmd:.}).
Thus, you could test whether an expression or variable {it:exp} was missing
with the expression {cmd:{it:exp}==.}.  Starting with Stata 8, this method is
no longer correct.  {cmd:{it:exp}==.} now means that the expression {it:exp}
equals a specific missing value, namely, sysmiss {cmd:.}.  {cmd:{it:exp}==.}
returns false if {it:exp} equals one of the extended missing-value types such
as {cmd:.a} or {cmd:.z}.  To test whether {it:exp} is missing, that is, equals
either {cmd:.} or one of the extended missing values, one should use the
expression

	{it:exp} {cmd:>= .}
    or
	{cmd:missing(}{it:exp}{cmd:)}

    which can be abbreviated to

	{cmd:mi(}{it:exp}{cmd:)}

{pstd}
To test that {it:exp} is not missing, use one of the forms

	{it:exp} {cmd:< .}
	{cmd:!missing(}{it:exp}{cmd:)}
	{cmd:!mi(}{it:exp}{cmd:)}

{pstd}
An advantage of the last two forms is that the missing functions
{cmd:missing()} and {cmd:mi()} allow multiple (numeric or string) arguments
to test whether any of the arguments is missing.

{pstd}
Old programs and do-files will continue to work using the old method, as
long as the version is set to 7 or less.  See {manhelp version P}.
{p_end}
