SAS Component Language Dictionary |
Category: | Command |
Syntax | |
Details | |
Examples | |
Example 1: Using WORD to Return the Value of the Command | |
Example 2: Using WORD to Return an Alphanumeric Value | |
See Also |
Syntax |
word-text=WORD(word-pos<,case>); |
is the position of the word to be retrieved from the command line. Specify either 1, 2, or 3 for the first, second, or third word.
is the type of case conversion to be performed:
'L' | |
'U' |
By default, SAS leaves all commands in the case in which they are entered.
Details |
WORD returns the first, second, or third word of the command that was issued. A word is the text from the current position up to the next token, such as the end of a leading number, a blank, an operator, or a semicolon.
Note: To retrieve more than three words, use NEXTWORD.
To support custom commands in your application, you must use a CONTROL statement with either the ENTER, ALWAYS, or ALLCMDS option specified. When one of these options is specified in the CONTROL statement and when multiple commands are specified on the command line (separated by semicolons), the MAIN section is executed for each command. MAIN is executed only once if only one command is entered.
When CONTROL ALWAYS is specified, words entered on the command line that are not valid SAS commands are not flagged in error. See CONTROL for information about the advantages of each CONTROL statement option before deciding which is best for your application.
WORD cannot capture windowing environment global commands, because the SCL program is not executed when a SAS windowing environment command is issued.
Examples |
Suppose a user types the command AXX BXX CXX DXX on the command line. Use WORD to return the value of the command.
word1=word(1); put "word1 is " word1; word2=word(2); put "word2 is " word2; word3=word(3); put "word3 is " word3; /* to retrieve more than three words, use NEXTWORD. */ call nextword(); word4=word(3); put "word4 is " word4;
The following output is produced:
word1 is AXX word2 is BXX word3 is CXX word4 is DXX
Suppose the user enters 123abc on the command line of the frame. Use WORD to return the value of the command.
init: control enter; return; main: dcl char word1 word2; word1=word(1); word2=word(2); put word1= word2=; return;
The following output is produced:
word1=123 word2=abc
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.