PING  0.9
Statistical data handling and processing in production environment
clist_compare

Compare two lists of comma-separated and quote-enhanced items, i.e check whether the items in one list differ from those in another not taking into account any order or repetition(s).

%let ans=%clist_compare(clist1, clist2, casense=no, mark=%str(%"), sep=%quote(,));

Arguments

  • clist1, clist2 : two lists of items comma-separated by a delimiter (e.g., quotes) and in between parentheses;
  • casense : (option) boolean flag (yes/no) set to perform cases sensitive search/matching; default: casense=no, i.e. the upper-case elements in both lists are matched;
  • mark, sep : (option) characters/strings used respectively as a "quote" and a separator in the input list; default: mark=str(%"), and" sep=%quote(,), i.e. the input clist1 and clist2 are both comma-separated lists of quote-enhanced items; see %clist_unquote for further details.

Returns

ans : the boolean result of the comparison test, i.e.:

  • 0 when both lists are equal: list1 = list2,
  • -1 when clist1 items are all included in clist2 (but the opposite does not stand): say it otherwise: list1 < list2,
  • 1 when clist2 items are all included in clist1 (but the opposite does not stand): say it otherwise: list1 > list2,
  • empty (i.e. ans=) when they differ.

Examples

%let clist1=("DE","AT","BE","NL","UK","SE");
%let ans=%clist_compare(&clist1, &clist1);

returns ans=0, while:

%let clist2=("AT","BE","NL");
%let ans=%clist_compare(&clist1, &clist2);

returns ans=1.

Run macro %_example_clist_compare for more examples.

Note

The macro will not return exactly what you want if the symbol $ appears somewhere in the list. If you need to use $, you can reset the global macro variable G_PING_UNLIKELY_CHAR (see _setup_ file) to another dumb (unlikely) character of your own.

See also

%list_compare, %clist_unquote.