In SAS, Inorder to identify SAS Variables starting with an alphabet one can use the colon modifiers (i.e. =: ‘Alphabet’, >: ‘Alphabet’ and <: lphabet="" span="">) to test for character strings prefixed with the alphabet.
/*Eg. 3 records starting with J for char variable a1*/ |
John Sawyer Sharon Michael |
Pamela Tiger Woods Peyton; |
/* We can use the : to identify obs for which a1 starts with J */ |
var a:; /*display variables that start with |
In a SQL step…
However in SQL, the datastep colon modifiers (i.e. =: ‘Alphabet’, >: ‘Alphabet’ and <: lphabet="" span="">‘) do not work….But fortunately SAS provided string comparison operators as below to achieve similar tasks…
Truncated string comparison operators are used to compare two strings. They differ from conventional comparison operators in that, before executing the comparison, PROC SQL truncates the longer string to be the same length as the shorter string. The truncation is performed internally; neither operand is permanently changed. The following table lists the truncated comparison operators:
Truncated String 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’; |
/* The same as above but with eqt comparison operators */ |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.