Truncated String Comparison Operators

Why Should You Use Truncated String Comparison Operators?

  • Post author:
  • Post category:PROC SQL
  • Post comments:0 Comments
  • Reading time:4 mins read

The dataset can use the Truncated String Comparison Operators (such as =:, >:, and <=:) for truncated string comparisons. However, you find that the Colon operator is not available in PROC SQL.

In Proc SQL, you can use the Truncated String Operators such as EQT, GTT, LTT, GET, LET and NET.

The truncated string comparison operator is used to compare two strings. The difference between PROC SQL and conventional comparison operators is that it trims the longer string to the same length as the shorter string before executing the comparison.

Both operands remain unchanged when the truncation is performed internally. The following table lists the truncated comparison operators:

Symbol Definition Example
EQT equal to truncated strings where Name eqt ‘Aust’;
GTT greater than truncated strings where Name gtt ‘Bah’;
LTT less than truncated strings where Name ltt ‘An’;
GET greater than or equal to truncated strings where Country get ‘United A’;
LET less than or equal to truncated strings where Lastname let ‘Smith’;
NET not equal to truncated strings where Style net ‘TWO’;
Truncated String Comparison Operators

The following example returns a list of Countries that have 'CO' at the beginning of their names:

proc sql;
Title "List of countries beginning with the characters'CO'";
	select Name from sashelp.demographics where Name eqt 'CO';
quit;

Output:

Truncated String Comparison Operators
Truncated String Comparison Operators

The following example returns a list of countries that have 'U' to ‘Z‘ at the beginning of their names:

proc sql;
Title 'List of countries beginning with the letter 'U' and later';
	select Name from sashelp.demographics where Name get 'U';
quit;

Output:

Why Should You Use Truncated String Comparison Operators?
Truncated String Comparison Operators

So, this was our side on Truncated String Comparison Operators In Proc SQL. We hope that you must have found it helpful.

Moreover, suggest suggestions in the comment section below if you have other suggestions. We will take those lists in our further blog post.

Thanks for reading!

Do you have any tips to add? Let us know in the comments.

Please subscribe to our mailing list for weekly updates. You can also find us on Instagram and Facebook.

Every week we'll send you SAS tips and in-depth tutorials

JOIN OUR COMMUNITY OF SAS Programmers!

Subhro

Subhro provides valuable and informative content on SAS, offering a comprehensive understanding of SAS concepts. We have been creating SAS tutorials since 2019, and 9to5sas has become one of the leading free SAS resources available on the internet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.