Loading...

String Functions of Advanced SAS

String functions can be very useful for the processing of complex data sets and for sub setting data sets according to values contained within strings. Some commonly used string functions include:

• COMPRESS (string) returns a new string that has blanks removed and then padded at the end of the string.

 • INDIER (string, value) returns the position in the string where the first character of value begins within the string. If value is not contained within the string, then the function returns zero. Thus, it is very useful for checking for the presence or absence of a certain value in a string variable, such as testing that a string variable contains the last name of a particular person.

• LEFT (string) will left align a character string by removing any leading blanks from the string. Note that the string's length is not changed by this function.

• LENGTH (string) returns the "length" of a string. Here, the "length" is defined to be the position of the right-most non-blank character in the string, rather than the number of characters reserved for storage of the string.

• LOWCASE (string) converts all uppercase characters to lowercase characters in string.

• RIGHT (string) will right align a character string by removing trailing blanks from the end of the string and inserting them at the beginning of the string. Thus, it does not change the length of the string.

• SCAN (string, n, delimiters) returns the nth word from the character string, where words are delimited by the characters in delimiters. If delimiters are omitted from the function, then blanks and most punctuation and special characters are used as the delimiters. Consult the SAS help or SAS/BASE documentation. If there are fewer words in the string than given by n, then a blank character string is returned.

• SUBSTR (string, start, n) returns a substring or part of string beginning with the character at the position start in the string and continuing for n characters. If n is omitted, then the remainder of the string is extracted.

• SUBSTR (string1, start) =string2 replaces the characters in string1 beginning at position start in string1 with string2.

• TRIM (string) returns a new string whose trailing blanks have been removed and whose length corresponds with the position of the last non-blank character in string. A blank string, however, is returned as a string with one blank character.

• TRIMN (string) is like TRIM (string), but a blank string is returned as a null string (length of zero).

• UPCASE (string) returns a new string will any lowercase characters replaced with their uppercase counterparts

String-Functions
VirtualNuggets 5569767946796312651

Post a Comment

emo-but-icon

Home item

Blog Archive

Popular Posts

Random Posts

Flickr Photo