PING  0.9
Statistical data handling and processing in production environment
list_append

Append (i.e., concatenate) a unformatted (char or numeric) list to another, possibly interleaving the elements in the lists.

%let conc=%list_append(list1, list2, zip=no, longest=no, sep=%quote( ), rep=%quote( ));

Arguments

  • list1, list2 : two lists of unformatted of numeric/strings;
  • zip : (option) a boolean flag (yes/no) or a character separator set to interleave the lists; when zip=yes, the i-th element from each of the lists are appended together and put into the 2*i-1 element of the output list; the returned list is truncated in length to the length of the shortest list; similarly, when zip is set to a special character, the lists are interleaved as before and this character is used as a separator between the zipped elements; when zip=_EMPTY_, items are zipped without separation, while when zip=_BLANK_, they are zipped with a blank space; default: zip=no, i.e. lists are simply appended;
  • longest : (option) a boolean flag (yes/no) used when zip^=NO; it is set to yes when the lists are uneven and the zipping (concatenation) shall be operated until the longest list is exhausted; in that case, the last item of the shortest list is used in the concatenation (see example below); default: longest=no;
  • sep : (option) character/string separator in input list; default: %quote( );
  • rep : (option) replacement character/string separator in outptu list; default: rep=&sep;

Returns

conc : output concatenated list of characters, i.e. the list obtained as the union or concatenation of the input lists list1 and list2, which is of the form:

  • a11&zip.a21&sep.a12&zip.a22&sep... when zip is not a boolean flag, +a11 a21&sep.a12 a22&sep... otherwise, where a1i is the i-th element of the list1, ibid for a2j;

Examples

%let list1=A B C D E;
%let list2=F G H I J;
%let conc=%list_append(&list1, &list2);

returns: conc=A B C D E F G H I J.

%let list0=1 2 3;
%let conc=%list_append(&list0, &list1, zip=yes);

returns: conc=1 A 2 B 3 C, while:

%let list0=1 2 3;
%let conc=%list_append(&list0, &list1, zip=yes, longest=yes);

returns: conc=1 A 2 B 3 C 3 D 3 E, and:

%let conc=%list_append(&list0, &list1, zip=%str(-));

returns: conc=1 - A 2 - B 3 - C, and:

%let conc=%list_append(&list0, &list1, zip=yes, rep=%str(, ));

returns: conc=1 A, 2 B, 3 C.

Run macro %_example_list_append for more examples.

See also

%clist_append, %clist_difference.