PING  0.9
Statistical data handling and processing in production environment
clist_unquote

Transform a parentheses-enclosed, comma-separated, and quote-enhanced list of items into an unformatted/unquoted list.

%let list=%clist_unquote(clist, mark=%str(%"), sep=%quote(,), rep=%quote( ));

Arguments

  • clist : a list of items comma-separated by a delimiter (e.g., quotes) and in between parentheses;
  • mark : (option) character/string used as "quote" the elements in the input list; note the particular case where it is passed as mark=_EMPTY_ then it is set to mark=%quote(); default: mark is the double quote ";
  • sep : (option) character/string separator in input list; default: %quote(,), i.e. sep the input list is comma separated;
  • rep : (option) character/string used to replace the separator in the output list; default: %quote( ), i.e. rep is blank by default.

Returns

list : output unformatted list of (unquoted) strings.

Examples

%let clist=("A","B","C","D","E");
%let list=%clist_unquote(&clist);

returns list=A B C D E.

Run macro %_example_clist_unquote for more examples.

Notes

  1. The following command:
%let clist=(A,B,C,D,E);
%let list=%clist_unquote(&clist, mark=_EMPTY_);

returns list=A B C D E, while other possible uses include:

%let var1="a,b,c";
%put %clist_unquote(%quote(%(&var1%)), sep=%quote( ));
%let var2=("a,b,c");
%put %clist_unquote(&var2, sep=%quote( ));
%let var3=("a"/"b"/"c");
%put %clist_unquote(&var3, sep=%quote(/), rep=%quote(,));

which all display a,b,c.

  1. The macro also deals with "empty" items, e.g.:
%let clist=("A",,,"D","E");
%let list=%clist_unquote(&clist, mark=_EMPTY_);

will return list=A D E.

  1. Finally note the idempotence:
%let clist1=("A","B","C","D","E");
%let clist2=(%list_quote(%clist_unquote(&clist1)));

since then clist1=clist2.

References

(see also references in %list_quote)

  1. Carpenter, A.L. (1999): "Macro quoting functions, other special character masking tools, and how to use them".
  2. Whitlock, I. (2003): "A serious look macro quoting".
  3. Chaudhary, K.R. (2015): "Essentials of macro quoting functions in SAS".

See also

%list_quote, TRANWRD, COMPBL, COMPRESS, FIND, UNQUOTE.