This is how the base explain prep guide explains INDEX and FIND.
I don't know about you but to me, the author seems to rewrite the same thing but in three separate sentences for INDEX and FIND respectively.
Both search specific string/substring from left to right, looking for first occurrence of the string/substring, if nothing is found return 0.
only difference I see is
INDEX is for string while
FIND is for subtring.
But the book never explains what the difference is between a string and a substring in this context.
using the example in the book
data work.datapool; set cert.temp; index = index(job,'word processing'); find = find(job,'word processing'); run; proc print data=work.datapool;run;
the result is the same
so I am guessing in context "word processing" is both a string and a substring if I go by the prep guide explanation of the FIND and INDEX?
There is a lot of overlap between FIND and INDEX. In many cases, they produce the same answers.
FIND has additional options not in INDEX. For some reason, the documentation you show doesn't mention these additional options. Here is the full documentation for FIND.
I don't think there is a difference between "string" and "substring" in this context. I can see how it may be confusing to see these two functions presented side by side, and you're trying to figure out what the difference is, and the only difference you see is in that wording. I think the difference in wording likely comes from the documentation, and is a result of FIND being introduced in a much later version than INDEX.
If you look in the documentation for a function, there is often a section at the bottom which explains how a function differs from similar functions. For FIND, it says:
The FIND function and the INDEX function both search for substrings of characters in a character string. However, the INDEX function does not have the modifier nor the start-position arguments.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.