SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3

Returns the position and length of a given word from a character expression, and ignores delimiters that are enclosed in quotation marks

Category: Character

Syntax

CALL SCANQ ( string , n , position , length <, delimiters >);

Arguments

string

n

position

length

delimiters

Details

In the context of the CALL SCANQ routine, 'word' refers to a substring that

If the value of the character string contains quotation marks, CALL SCANQ ignores delimiters inside the strings in quotation marks. If the value of the character string contains unmatched quotation marks, then scanning from left to right will produce different words than scanning from right to left.

Delimiters that are located before the first word or after the last word in the character string do not affect the CALL SCANQ routine. If two or more contiguous delimiters exist, CALL SCANQ treats them as one.

To retrieve the designated word as a character string after the call to CALL SCANQ, use the following function:

substrn(string, position, length)

Comparisons

The CALL SCANQ routine ignores delimiters that are enclosed in quotation marks. CALL SCAN does not.

Examples

The following example shows how you can use the CALL SCANQ routine.

options pageno=1 nodate ls=80 ps=64; data artists2; input string .; drop string; do i=1 to 99; call scanq(string, i, position, length); if not position then leave; Name=substrn(string, position, length); output; end; datalines; Picasso Toulouse-Lautrec Turner "Van Gogh" Velazquez ; proc print data=artists2; run;

Output 4.16: SAS Output from the CALL SCANQ Routine

The SAS System 1 Obs i position length Name 1 1 1 7 Picasso 2 2 9 16 Toulouse-Lautrec 3 3 26 6 Turner 4 4 33 10 "Van Gogh" 5 5 44 9 Velazquez

 

See Also

Functions and CALL Routines:

Категории