KCOMPARE Function

Returns the result of a comparison of character expressions.
Category: DBCS
Tip: Non-DBCS equivalent function is the COMPARE Function in SAS Functions and CALL Routines: Reference.

Syntax

KCOMPARE(source,<pos, <count,>> findstr)

Required Arguments

source
specifies the character expression to be compared.
pos
specifies the starting position in source to begin the comparison. If pos is omitted, the entire source is compared. If pos is less than 0, source is assumed as extended DBCS data that does not contain any SO/SI characters.
count
specifies the number of bytes to compare. If count is omitted, all of source that follows pos is compared, except for any trailing blanks.
findstr
specifies the character expression to compare to source.

Details

KCOMPARE returns values as follows:
  • a negative value if source is less than findstr
  • 0 if source is equal to findstr
  • a positive value if source is greater than findstr