Searches a character expression for a string that is specified as a word, and returns the position of the first character in the word.
| Category: | Character |
| Restriction: | I18N Level 0 functions are designed for use with Single Byte Character Sets (SBCS) only. |
data temp;
infile datalines;
input name $12.;
datalines;
abcdef
abcdef
;
run;
data temp2;
set temp;
format name_list $1024.;
retain name_list ' ';
exists=indexw(name_list, trim(name), ';');
if exists=0 then do
name_list=catx(';', name_list, name)||';' ;
name_count +1;
put '-------------------------------';
put exists= ;
put name_list= ;
put name_count= ;
end;
run;------------------------------- exists=0 name_list=abcdef; name_count=1
x = indexw('ABCDEF;XYZ', 'ABCDE', ';');The only values for the second argument that would return a nonzero
result are ABCDEF and XYZ.data temp;
infile datalines;
input name $12.;
datalines;
abcdef
abcdef
;
run;
data temp2;
set temp;
format name_list $1024.;
retain name_list ' ';
exists=indexw(name_list, name, ' ');
if exists=0 then do
name_list=catx(' ', name_list, name) ;
name_count +1;
put '-------------------------------';
put exists= ;
put name_list= ;
put name_count= ;
end;
run;