Command Reference : Function Reference : Function Reference: N
  
 
@neqna
 
Inequality test (NAs and blanks treated as values, not missing).
Syntax: @neqna(arg1, arg2)
arg1: number or string
arg2: number or string
Return: integer
Tests for inequality of arg1 and arg2, treating NA values and null strings as ordinary values or blanks, and not as missing values. Simple inequality testing which propagates NAs may be performed using the “<>” binary comparison operator.
Arguments which test as equal return a 0, and 1 otherwise.
When used with series objects, the test is performed for every observation in the workfile sample. Note that when used with matrix objects, the comparison is an inequality test of all of the elements of the two matrices, and will return 0 if any element comparison is false. Individual element tests are available in @eneqna
Examples
The test
scalar f1 = @eqna(na, 2)
returns a 0, and not a missing value.
Consider the comparison
vector v1 = @fill(1, 2, 2)
scalar f2 = @neqna(v1, 2)
compares the entire vector V1 to 2, and returns 1 since some of the elements of V1 are equal to 2. Note that this is a full inequality test that returns a 0 if any element is equal, and a 1 if all elements are unequal (ignoring NAs)
If SER1 and SER2 are numeric series,
series s2 = @neqna(ser1, ser2)
tests SER1 and SER2 for inequality, ignoring NAs, for each observation in the workfile sample.
Define the string objects
string s1 = "abc"
string s2 = ""
Then
scalar b1 = @neqna("abc", "abc")
scalar b2 = @neqna("abc", s1)
sets the scalar objects B1 and B2 to 0, while
scalar c1 = @neqna("", "def")
scalar c2 = @neqna(s2, "def")
scalar c3 = @neqna(s1, s2)
sets C1, C2, and C3 to 1.
If ALPHA1 and ALPHA2 are alpha series,
series d1 = @neqna(alpha1, "abc")
series d2 = @neqna(alpha1, s1)
series d3 = @neqna(alpha1, alpha2)
perform the inequality test using ALPHA1 and the literal string and scalar containing “abc”, and the contents of ALPHA2 for each observation in the workfile sample.
If SVEC1 and SVEC2 are svectors,
scalar sc1 = @neqna(svec1, "abc")
scalar sc2 = @neqna(svec1, svec2)
perform the equality test of SVEC1 against “abc”, and the contents of SVEC2. Note that this is a full inequality test of SVEC1 against the string, or against each element of SVEC2, and that the test will return a 0 if any element is equal, and a 1 if all elements are unequal (ignoring empty strings).
Cross-references
See also @eeqna, @enisna and @eqna.