2. SAS FUNCTIONS INDEX / INDEXC / INDEXW
These functions search for the char / substring in a
string
It returns the values such as 0,1,2,…
It doesn’t return null value
It always search from left to right
It returns value of position of first occurance
These are case sensitive functions
3. SAS FUNCTIONS INDEX / INDEXC / INDEXW
• INDEX:
search for first occurance of substring
Syntax:
INDEX(string, substring)
EX: A=“hi,where is he”
Index(A,”he”) 5
4. SAS FUNCTIONS INDEX / INDEXC / INDEXW
• INDEXC:
Search for the first occurance of any one of char
value of subsring
Syntax:
1. INDEXC(string,”char1”,”char2”,”char3”…)
2. INDEXC(string,”char1char2char3…..”)
Ex: A=“hi,where is he”
INDEXC(A,”he”) 1
Here it searches for first ocurance of “h” or “e”
5. SAS FUNCTIONS INDEX / INDEXC / INDEXW
• INDEXW:
search for first occurance of specific word
Syntax:
INDEXW(string, word)
Ex: A=“hi,where is he”
INDEXW(A,”he”) 13
INDEX and INDEXW are similar, the difference being that
INDEXW looks for a word, while INDEX simply searchs for
the designated substring.