Samples from SAS.com
For these examples STRING = "ABCDEFG"
Code Return
INDEX(STRING,'C') 3 (the position of the 'C')
INDEX(STRING,'DEF') 4 (the position of the 'D')
INDEX(STRING,'X') 0 (no "X" in the string)
INDEX(STRING,'ACE') 0 (no "ACE" in the string)
It looks your code is OK. The following code may help to solve your problem.
%let X = "abcdefg";
%let A = "a";
%let F = "f";
%let H = "h";
data _null_;
if index(&X,&A) > 0 then %put A is &A;
if index(&X,&F) > 0 then %put F is &F;
if index(&X,&H) NG 0 then %put H is not found;;
Run;
