Loading...
Advanced SAS
Advanced SAS Programming
Corporate
Online
SAS
String Functions of Advanced SAS
VirtualNuggets
https://advancedsasonlinetraining.blogspot.com/2015/07/string-functions-of-advanced-sas.html
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).
Advanced SAS,
Advanced SAS Programming,
Corporate,
Online,
SAS,
String Functions of Advanced SAS,
VirtualNuggets
VirtualNuggets
5569767946796312651
Post a Comment
Home
item
Blog Archive
Popular Posts
-
String functions can be very useful for the processing of complex data sets and for sub setting data sets according to values contained ...
-
SAS dictionary tables contain the data at the back the scenes in SAS a.k.a. the metadata. The dictionary tables are only directly availa...
-
Creating dynamic, data driven programs is a very powerful tool. Often we can use the metadata or the project data itself to help write o...
-
1. Which of these is false? Ranges in the VALUE statement can specify… 1. a single value, such as 24 or ‘S’ 2. a range ...
-
There are several ways to improve query performance, including the following: · using indexes and composite indexes · ...
-
· Demonstrate advanced data set processing techniques such as updating master data sets, transposing data, combining/merging data...
-
SAS macro variables are part of the macro facility, which is a tool for extending and customizing SAS software. These Macro variables fa...