Statistical Analysis System (SAS) Programming Certification Practice Exam

Question: 1 / 400

What function is used to find the position of a substring within a string in SAS?

SUBSTR

INDEX

The function used to find the position of a substring within a string in SAS is INDEX. This function searches for the specified substring within a given string and returns the starting position of the first occurrence of that substring. If the substring is not found, INDEX will return zero.

Using INDEX is straightforward. For instance, if you want to find where "cat" appears in the string "The cat sat on the mat," calling INDEX with these parameters would yield a number representing the first position of "cat" in the string.

While SUBSTR is useful for extracting a portion of a string based on specified starting positions and lengths, it does not perform searches. FIND is similar to INDEX, but it is used in SAS to search for a substring as well, though it has more options for case sensitivity and other parameters. POSITION isn't a recognized function in SAS for this purpose. Hence, INDEX stands out as the correct function to locate the starting position of a substring within a string.

Get further explanation with Examzify DeepDiveBeta

FIND

POSITION

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy