SAS Component Language Dictionary |
Category: | Command |
Syntax | |
Details | |
Example |
Syntax |
rc=LOOKUPC(string,token-1<, . . .,token-12>); |
contains the return code for the operation:
0 | |
>0 |
is the position in the token list if a unique match was found. |
<0 |
is the negative of the position in the token list if a duplicate token was found. |
Details |
A token can be a name, a literal, digits, or special characters. This function is useful for looking up valid commands.
The function accepts abbreviations as valid commands. That is, the function reports a match if the search string matches the starting characters of a token.
LOOKUPC does not search the token list for embedded strings. For example, the search string LIST would not be found in the token NEWLIST.
Example |
Get the command (SURVEY, NEWLIST, or ADDNAME) that the user issued from the command line, and execute code accordingly:
array cmds{*} $8 ('SURVEY','NEWLIST','ADDNAME'); INIT: control always; return; MAIN: cmdword=WORD(1,'u'); cmdnum=lookupc(cmdword,cmds{1},cmds{2},cmds{3}); select; when (cmdnum=1) ...SCL statements to process SURVEY command... when (cmdnum=2) ...SCL statements to process NEWLIST command... when (cmdnum=3) ...SCL statements to process ADDNAME command... otherwise _msg_='Command conflict'; end;
In this example, SUR, NEWL, and ADDN are considered valid commands.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.