Command Reference : String and Date Function Reference
  
 
@eqna
Tests for equality of two strings.
Syntax: @eqna(str1, str2)
str1: string
str2: string
Return: integer
Tests for equality of the strings in str1 and str2, treating null strings as ordinary blank strings, and not as missing values.
Return value is an integer (0, 1). Strings which test as equal return a 1, and 0 otherwise.
Simple inequality testing which propagates null string NAs may be performed using the “=” binary comparison operator.
Examples
Define the string objects
string s1 = "abc"
string s2 = ""
Then
scalar b1 = @eqna("abc", "abc")
scalar b2 = @eqna("abc", s1)
sets the scalar objects B1 and B2 to 1, while
scalar c1 = @eqna("", "def")
scalar c2 = @eqna(s2, "def")
scalar c3 = @eqna(s1, s2)
sets C1, C2, and C3 to 0.
If ALPHA1 and ALPHA2 are alpha series,
series d1 = @eqna(alpha1, "abc")
series d2 = @eqna(alpha1, s1)
series d3 = @eqna(alpha1, alpha2)
perform the equality test using ALPHA1 and ALPHA2 for each observations in the workfile sample.
If SVEC1 and SVEC2 are svectors,
scalar sc1 = @eqna(svec1, "abc")
scalar sc2 = @eqna(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 not equal, and a 1 if all elements are equal (ignoring empty strings).
Cross-references
See also @isempty and @neqna.