Chapter Contents

Previous

Next
SCAN

SCAN



Selects a given word from a character expression

Category: Character


Syntax
Arguments
Details
Examples

Syntax

SCAN(argument,n<, delimiters>)

Arguments

argument
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.
Tip: 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.

delimiters
specifies a character expression that produces characters that you want SCAN to use as word separators in the character string.
Default: If you omit delimiters in an ASCII environment, SAS uses the following characters:
blank . < ( + & ! $ * ) ; ^ - / , % |
In ASCII environments without the ^ character, SCAN uses the ~ character instead.

If you omit delimiters on an EBCDIC environment, SAS uses the following characters:
blank . < ( + | & ! $ * ) ; ¬ - / , % | ¢

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


Details

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


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.