42.The following SAS program is submitted:
data WORK.ONE;
Text='Australia, US, Denmark';
Pos=find(Text,'US','i',5);
run;
What value will SAS assign to Pos?
A. 0
B. 1
C. 2
D. 12
Answer: D
本文属于博客:http://www.crackman.net/版权归作者所有,欢迎转载!如有转载,请务必注明出处!未经本文作者同意不得用于商业应用。
本题考察的是SAS中FIND函数的应用。
POS=FIND(Text,'US','i',5)解释为:
从Australia, US, Denmark 字符串的第五个字符开始,忽略字符串中大小写,寻找字符串US在源字符串中的起始位置,并返回起始位置的数字给POS。
几个问题值得思考,第一个是如果没有'i'这个参数,结果会怎么样?如果把5改成1,那么结果又如何?
看看SAS官网网站的解释:
Syntax
FIND(string,substring<,modifiers><,startpos>)
FIND(string,substring<,startpos><,modifiers>)
Searches for a specific substring of characters within a character string.
Arguments
string
specifies a character constant, variable, or expression that will be searched for substrings.
Tip: Enclose a literal string of characters in quotation marks.
substring
is a character constant, variable, or expression that specifies the substring of characters to search for in string.
Tip: Enclose a literal string of characters in quotation marks.
modifiers
is a character constant, variable, or expression that specifies one or more modifiers. The following modifiers can be in uppercase or lowercase:
i ignores character case during the search. If this modifier is not specified, FIND only searches for character substrings with the same case as the characters in substring.
t trims trailing blanks from string and substring.
Note: If you want to remove trailing blanks from only one character argument instead of both (or all) character arguments, use the TRIM function instead of the FIND function with the T modifier.
Tip: If modifier is a constant, enclose it in quotation marks. Specify multiple constants in a single set of quotation marks. Modifier can also be expressed as a variable or an expression.
startpos
is a numeric constant, variable, or expression with an integer value that specifies the position at which the search should start and the direction of the search.
|