SAS String Functions


Find

The FIND function returns the character position of a pattern in a string expression, or else returns 0. The final argument is a modifier.

For example, to scan for a pattern case insensitively (I), try:

foo = substr(foobar, find(foobar, 'FOO', 'i'), 3);

And to trim trailing whitespace from the string expression and/or the pattern (T), try:

foo = substr(foobar, find(foobar, 'foo       ', 't'), 3);


Index

The INDEX function returns the character position of a pattern in a string expression, or else returns 0.

foo = substr(foobar, index(foobar, 'foo'), 3);


LowCase


PropCase


PrxMatch

The PRXMATCH function returns the character position of a regular expression in a string expression, or else returns 0.

foo = substr(foobar, prxmatch("/[Ff][Oo]{2}/", foobar);, 3);


PrxParse

Compile a regular expression. This can beb used like:

if _N_ = 1 then PATTERN = prxparse("/[Ff][Oo]{2}/");
retain PATTERN;

mystart = prxmatch(PATTERN, foobar);

SubStr

The SUBSTR function returns the substring of a string expression from a character position to a character length.

foo = substr('foobar', index(foobar, 'foo'), 3);


UpCase


CategoryRicottone

SAS/StringFunctions (last edited 2023-01-14 04:55:33 by DominicRicottone)