Core Distinction

• INDEX(string, 'CAT') searches for the entire word / substring 'CAT' in that exact sequence.
• INDEXC(string, 'C', 'A', 'T') searches for the first occurrence of ANY individual character (either 'C', 'A', or 'T').

Comparison by Example #

Suppose you have a text variable containing the company name: text = "ACTUATOR";

DATA work.compare;
    text = "ACTUATOR";
    
    /* Look for the sequence 'CAT' */
    pos_index  = index(text, 'CAT');   /* Returns 0 (not found) */
    
    /* Look for any character 'C', 'A', or 'T' */
    pos_indexc = indexc(text, 'CAT');  /* Returns 1 (finds 'A' at position 1) */
RUN;
Direct Summary: The INDEX function searches for the exact multi-character substring sequence in contiguous order, while INDEXC searches for the first occurrence of any single individual character listed in the search string argument.
Function Target Search Match Type Result on "ACTUATOR"
INDEX 'CAT' Exact Substring 0 (No Match)
INDEXC 'CAT' Any Individual Character 1 (Found 'A')

Master Advanced SAS Functions & Data Processing #

Advance your programming skills with comprehensive character, numeric, date, and macro string manipulation lessons.

Explore SAS Programming Mastery →