The SUBSTRING function
operates on character strings. SUBSTRING returns a specified part
of the input character string, beginning at the position that is specified
by start. If length is omitted, then the SUBSTRING function returns
all characters from start to the end of the input character string.
The values of start and length must be numbers (not variables) and
can be positive, negative, or zero.
If start is greater
than the length of the input character string, then the SUBSTRING
function returns a zero-length string.
If start is less than
1, then the SUBSTRING function begins extraction at the beginning
of the input character string.
If length is specified,
then the sum of start and length cannot be less than start or an error
is returned. If the sum of start and length is greater than the length
of the input character string, then the SUBSTRING function returns
all characters from start to the end of the input character string.
If the sum of start and length is less than 1, then the SUBSTRING
function returns a zero-length string.
Note: The SUBSTRING function is
provided for compatibility with the ANSI SQL standard. You can also
use the SAS function SUBSTR.