Comparing data that contains missing values can return misleading results unless you specify a condition that is always true or use functions such as Is Missing() or Zero Or Missing(). Comparisons of data with mismatched types (numeric versus character) or data in matrices can also be confusing.
Some Special-Case Comparison Tests shows examples of such comparisons and matrices and explanations of the results. For a review of operators used in comparisons, see Operators. The sections that follow the table provide more details about comparison and logical operators.
 Test Result Explanation m=.; m==1 . An equality test with a missing value returns missing. m=.; m!=1 . An inequality test with a missing value returns missing. m=.; m<1; m>1; and so on . A comparison with a missing value returns missing (unless it could not possibly be true, see next). m=.; 1
 If( Begins the comparison. :A, "true", If the value of A is nonmissing and nonzero, the result is "true". This comparison is true for the first three rows. 1, "false" The value of 1 is always true, so the missing value returns "false". ) Closes the comparison.
 • If one value is true and another is missing, Or() returns true. (Only one value in an Or() test needs to be true to get a true result.)
 • If one value is false and another is missing, And() returns false. (Both values in an And() test must be true to get a true result.)
If you know that some values are missing, you can also compare with Is Missing(). The comparison in the preceding example can be rewritten to return "missing" for missing values:
If the missing value could be 0, use the Zero Or Missing() function instead: