SCAN Function


Selects a given word from a character expression

Category: Character

Syntax

SCAN ( string ,n <, delimiter (s) >)

Arguments

string

  • specifies any character expression.

n

  • specifies a numeric expression that produces the number of the word in the character string you want SCAN to select. The following rules apply:

    • If n is negative, SCAN selects the word in the character string starting from the end of the string.

    • If n is greater than the number of words in the character string, SCAN returns a blank value.

delimiter

  • specifies a character expression that produces characters that you want SCAN to use as a word separator in the character string.

  • Default: If you omit delimiter in an ASCII environment, SAS uses the following characters:

    • blank . < ( + & ! $ * ); ^ - / , %

    • In ASCII environments without the ^ character, SCAN uses the ~ character instead.

    • If you omit delimiter in an EBCDIC environment, SAS uses the following characters:

    • blank . < ( + & ! $ * ); -/,% ¢

  • Tip: If you represent delimiter as a constant, enclose delimiter in quotation marks.

Details

If the SCAN function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 200.

Leading delimiters before the first word in the character string do not effect SCAN. If there are two or more contiguous delimiters, SCAN treats them as one.

Examples

SAS Statements

Results

arg= ' ABC.DEF(X=Y) ' ;

word=scan(arg,3);

put word;

X=Y

word=scan(arg,-3);

put word;

ABC




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net