PING  0.9
Statistical data handling and processing in production environment
list_find

Find all the occurrences of an element in a list and returns the indices of its position in that list.

%let ind=%list_find(list, item, startind=1, startpos=1, casense=no, sep=%quote( ));

Arguments

  • list : a list of blank separated strings;
  • item : a string defining the pattern/element to look for in input list;
  • startind : (option) specifies the index of the item in list at which the search should start; incompatible with option startind above; default: startind, i.e. it is not considered;
  • startpos : (option) specifies the position in list at which the search should start and the direction of the search (see argument of function find); default: startpos=1; incompatible with option startind above; default: startpos, i.e. it is not considered;
  • casense : (option) boolean flag (yes/no) set to perform cases sensitive search/matching; default: casense=no, i.e. the upper-case pattern match will be searched/matched;
  • sep : (option) character/string separator in input list; default: %quote( ), i.e. sep is blank.

Returns

ind : output list of indexes, i.e. the positions of the element item in the list if it is found, and empty variable (i.e, ind=) otherwise.

Examples

Let us consider a simple example:

%let list=NL UK AT DE AT BE AT;
%let ind=%list_find(&list, AT);

which returns ind=3 5 7, while:

%let ind=%list_find(&list, AT, startind=4);

only returns ind=5 7.

Run macro %_example_list_find for more examples.

See also

%list_index, %list_slice, %list_count, %list_remove, %list_length, FIND, FINDW.