Chapter Contents |
Previous |
Next |
%SCAN and %QSCAN |
Type: | Macro functions | ||
See also: |
|
Syntax | |
Details | |
Comparisons | |
Example | |
Comparing the Actions of %SCAN and %QSCAN |
Syntax |
%SCAN(argument,n<,delimiters>) |
%QSCAN(argument,n<,delimiters>) |
If delimiters includes any of the default delimiters for your system, the remaining default delimiters are treated as text.
To determine if you are using an ASCII or EBCDIC system, see the SAS companion for your operating system.
Details |
The %SCAN and %QSCAN functions search argument and return the nth word. A word is one or more characters separated by one or more delimiters.
%SCAN does not mask special characters or mnemonic operators in its result, even when the argument was previously masked by a macro quoting function. %QSCAN masks the following special characters and mnemonic operators in its result:
& % ' " ( ) + - * / < > = ¬ ^ ~ ; , blank AND OR NOT EQ NE LE LT GE GT
Comparisons |
%QSCAN masks the same characters as the %NRBQUOTE function.
Example |
This example illustrates the actions of %SCAN and %QSCAN.
%macro a; aaaaaa %mend a; %macro b; bbbbbb %mend b; %macro c; cccccc %mend c; %let x=%nrstr(%a*%b*%c); %put X: &x; %put The third word in X, with SCAN: %scan(&x,3,*); %put The third word in X, with QSCAN: %qscan(&x,3,*);
The %PUT statement writes this line:
X: %a*%b*%c The third word in X, with SCAN: cccccc The third word in X, with QSCAN: %c
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.