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.
Table 4.5 shows examples of such comparisons and matrices and explanations of the results. For a review of operators used in comparisons, see Operators. For an overview of comparing data, see Comparison Functions in the JSL Syntax Reference.
m=.; m==1 |
. |
|
m=.; m!=1 |
. |
|
m=.; m<1; m>1; and so on |
. |
|
m=.; 1<m<0 |
0 |
|
{a, b}==List(a, b) |
1 |
|
{a, b}<{a, c} |
. |
|
1=="abc" |
0 |
|
1<="abc" |
. |
|
[1 2 3]==[2 2 5] |
[0 1 0] |
|
[1 2 3]==2 |
[0 1 0] |
|
[1 2 3] < [2 2 5] |
[1 0 1] |
|
[1 2 3] < 2 |
[1 0 0] |
|
Is Missing(m) |
1 |
|
Zero Or Missing(m) |
1 |
|
All([2 2]==[1 2]) |
0 |
Summarizes elementwise comparisons; returns 1 only if all comparisons are true and returns 0 otherwise.
|
Any([2 2]==[1 2]) |
1 |
Summarizes elementwise comparisons; returns 1 if any comparison is true and returns 0 otherwise.
|