Command Reference : String and Date Function Reference
String inequality.
Syntax: @neqna(str1, str2)
str1: string
str2: string
Return: integer
Tests for inequality of str1 and str2, treating null strings as ordinary blank strings, and not as missing values.
Strings which test as equal return a 0, and 1 otherwise.
Simple inequality testing which propagates null string NAs may be performed using the “<>” binary comparison operator.
Define the string objects
string s1 = "abc"
string s2 = ""
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 equality 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).
See also @isempty and @eqna.