HomeContact
Advanced SAS
Why Should You Use Truncated String Comparison Operators?
Subhro Kar
Subhro Kar
October 31, 2022
1 min
Why Should You Use Truncated String Comparison Operators?

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”:

SymbolDefinitionExample
EQTequal to truncated stringswhere Name eqt ‘Aust’;
GTTgreater than truncated stringswhere Name gtt ‘Bah’;
LTTless than truncated stringswhere Name ltt ‘An’;
GETgreater than or equal to truncated stringswhere Country get ‘United A’;
LETless than or equal to truncated stringswhere Lastname let ‘Smith’;
NETnot equal to truncated stringswhere 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](../../assets/how-to-use-truncated-string-comparison-operators-in-proc-sql/image-66.png)

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”:

image 65 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.


Share


Related Posts

Retrieving DBMS Data with a Pass-Through Query
May 29, 2024
2 min
© 2025 9to5sas
AboutContactPrivacyTerms