Missing Values and how to work with them
Stata represents missing values with a "." (period) in its results window. If the file has special missing values, Stata represents them as ".a", ".b", ... , ".z". Missing values are stored as values larger than the largest allowable number for the data type. For example, a variable stored as data type byte can take the following values:
You see: Stored as: Treated as: 1 1 1 2 2 2 ... ... ... 100 100 100 . 101 missing .a 102 missing .b 103 missing ... ... ... .z 127 missing
Most commands ignore missing values by default. Some commands, such as tabulate, have an option to display missing if you want to see how many missing observations there are. Other commands, however, may use missing values in a way that will surprise you. For example, the replace command does not ignore missing values. Here is a simple example to demonstrate how replace and recode handle missing values differently. In this example, we have three variables with the values of 1, 2, and missing. We want to change all values of 2 to 1.
clear input a b c 1 1 1 2 2 2 . . . end list replace a=1 if a>1 replace b=1 if b>1 & b<. recode c 1/max=1 list
The first replace command changes every value that's greater than 1 to 1. This command does not ignore missing values, so both 2 and missing are changed to 1. This probably is not what we would normally want to do, since missing values should remain missing.
The second replace command changes all values greater than 1 but less than missing to 1. In this case values of 2 are changed and missing values are not changed, which is our intention.
The recode command automatically ignores missing values, so we don't have to think about it. The results are the same as the second replace command.