SAS Base (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

Check Answer
Answer: D

注解:FIND function用于寻找字符串中某一个特定字符串片段的启示位置。题目中为:从’Australia, US, Denmark’中的第5个字符开始寻找’US’,’i’的作用是忽略大小写。忽略大小写之后,’Australia, US, Denmark’中有2处’US’,但由于是从第5个字符开始找,所以第一次出现’US’的位置是第12个字符(从’A’开始数,包括逗号空格)。

One thought to “SAS Base (42)”

Leave a Reply

Your email address will not be published. Required fields are marked *