<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Search/replace with special characters in macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142910#M28609</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additionally, if you really don't want to take out the commas you could use it in proc sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers=a,b,c;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select *, sum(&amp;amp;mynumbers) as sumnum&lt;/P&gt;&lt;P&gt;from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jan 2014 16:51:17 GMT</pubDate>
    <dc:creator>overmar</dc:creator>
    <dc:date>2014-01-16T16:51:17Z</dc:date>
    <item>
      <title>Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142907#M28606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a macro variable that stores a comma-separated list of field names, e.g.&lt;/P&gt;&lt;P&gt;%let mynumbers = a,b,c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I would like to do a search/replace to get a new macro variable like this&lt;/P&gt;&lt;P&gt;mynumbers_sum = sum(a),sum(b),sum(c)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a two-step solution that seems to work, however it is easy to see why I'm not happy with it:&lt;/P&gt;&lt;P&gt;/* step 1: add "sum(" and ")" at both ends and use tranwrd to replace commas by placeholder */&lt;/P&gt;&lt;P&gt;%let mynumbers_1 = sum(%sysfunc(tranwrd(%nrbquote(&amp;amp;mynumbers),%str(,),91sum6)));&lt;/P&gt;&lt;P&gt;/* step 2: use translate to replace each character in placeholder */&lt;/P&gt;&lt;P&gt;%let mynumbers_sum = %sysfunc(translate(%str(&amp;amp;mynumbers_1), ")", "9", ",", "1", "(", "6"));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone suggest a better/more elegant solution that does not rely on characters I'm not using in my macro variable values? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 10:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142907#M28606</guid>
      <dc:creator>titania</dc:creator>
      <dc:date>2014-01-16T10:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142908#M28607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use PROC SUMMARY no need to transform the list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers=a b c;&lt;/P&gt;&lt;P&gt;proc summary;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var &amp;amp;mynumbers;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output sum=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 12:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142908#M28607</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-01-16T12:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142909#M28608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not write it as an array, granted you would have to remove the commas, but it would solve the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers = a b c;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array fir (*) &amp;amp;mynumbers;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dim(fir);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mynumsum = sum (of fir(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 16:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142909#M28608</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-16T16:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142910#M28609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Additionally, if you really don't want to take out the commas you could use it in proc sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers=a,b,c;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select *, sum(&amp;amp;mynumbers) as sumnum&lt;/P&gt;&lt;P&gt;from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 16:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142910#M28609</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-16T16:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142911#M28610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how or where you want to use the macro variable &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;mynumbers_sum, but&lt;/SPAN&gt; for the text substitution you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;/* take a comma separated list and add sum() around items */&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro sumlist(list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %if not %index(%quote(&amp;amp;list),%str(,)) %then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(&amp;amp;list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(%scan(%quote(&amp;amp;list),1)),%sumlist(%quote(%substr(%quote(&amp;amp;list),%eval(%index(%quote(&amp;amp;list),%str(,))+1))));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend sumlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;/* test macro sumlist */&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%let mynumbers = a,b,c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let mynumbers_sum=%sumlist(%quote(&amp;amp;mynumbers));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put mynumbers_sum=&amp;amp;mynumbers_sum;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 17:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142911#M28610</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2014-01-16T17:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142912#M28611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are asking me? &lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;overmar wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Why not write it as an array, granted you would have to remove the commas, but it would solve the problem.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;%let mynumbers = a b c;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array fir (*) &amp;amp;mynumbers;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to dim(fir);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mynumsum = sum (of fir(*));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 17:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142912#M28611</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-01-16T17:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142913#M28612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry no, i was using the phrase as a juxtaposition and suggesting another alternative as your solution would also work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 18:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142913#M28612</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-16T18:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142914#M28613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just quote it properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers = a,b,c;&lt;/P&gt;&lt;P&gt;%put sum(%sysfunc(tranwrd(%superq(mynumbers),%str(,),%str(%),sum%())));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(a),sum(b),sum(c)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 01:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142914#M28613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-01-17T01:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142915#M28614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just another way of doing it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mynumbers = a,b,c, d_5a;&lt;BR /&gt;%put %sysfunc(prxchange(s/(\w+)/sum(\1)/oi,-1,%bquote(&amp;amp;mynumbers)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(a),sum(b),sum(c), sum(d_5a)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 06:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142915#M28614</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-17T06:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142916#M28615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My advice:&amp;nbsp; don't use commas in macro variable lists.&amp;nbsp; You just open yourself to a world of headaches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead, store your list as a (non-comma) delimited list.&amp;nbsp; If your list data contains spaces (eg. file paths on Windows), use some other delimiter.&amp;nbsp; Then, use a helper macro, and add the commas at "run time" when you need them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a huge fan of Richard Devenezia, and I encourage you to visit his macros website:&amp;nbsp; &lt;A href="http://www.devenezia.com/downloads/sas/macros/index.php" title="http://www.devenezia.com/downloads/sas/macros/index.php"&gt;SAS Macros - by Richard A. DeVenezia - &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In particular, download the %seplist macro.&amp;nbsp; It makes it dead easy to switch between data step (space delimited) and SQL (comma delimited) lists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also attached a %loop macro which I wrote - there are various versions "out there".&amp;nbsp; Remove the call to %parmv.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have either of these macros compiled, your code then becomes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=a b c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %seplist(&amp;amp;list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %seplist(&amp;amp;list,prefix=sum&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%str&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(%(), suffix=&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%str&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(%)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;code&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%if&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;__iter__ gt &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;1&lt;/SPAN&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%then&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; ,;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;sum(&amp;amp;word)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %loop(&amp;amp;list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%let&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; list=a list ^ containing spaces;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %seplist(&amp;amp;list,indlm=^);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %seplist(&amp;amp;list,indlm=^,prefix=sum&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%str&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(%(), suffix=&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%str&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(%)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'SAS Monospace';"&gt;%put&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %loop(&amp;amp;list,dlm=^);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;Output:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let list=a b c;&lt;/P&gt;&lt;P&gt;16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %seplist(&amp;amp;list);&lt;/P&gt;&lt;P&gt;a,b,c&lt;/P&gt;&lt;P&gt;18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %seplist(&amp;amp;list,prefix=sum%str(%(), suffix=%str(%)));&lt;/P&gt;&lt;P&gt;sum(a),sum(b),sum(c)&lt;/P&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %macro code;&lt;/P&gt;&lt;P&gt;21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;__iter__ gt 1 %then ,;&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(&amp;amp;word)&lt;/P&gt;&lt;P&gt;23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %mend;&lt;/P&gt;&lt;P&gt;24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %loop(&amp;amp;list);&lt;/P&gt;&lt;P&gt;sum(a) , sum(b) , sum(c)&lt;/P&gt;&lt;P&gt;25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;26&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let list=a list ^ containing spaces;&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %seplist(&amp;amp;list,indlm=^);&lt;/P&gt;&lt;P&gt;a list,containing spaces&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %seplist(&amp;amp;list,indlm=^,prefix=sum%str(%(), suffix=%str(%)));&lt;/P&gt;&lt;P&gt;sum(a list),sum(containing spaces)&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %loop(&amp;amp;list,dlm=^);&lt;/P&gt;&lt;P&gt;sum(a list) , sum(containing spaces)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 14:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142916#M28615</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2014-01-17T14:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Search/replace with special characters in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142917#M28616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So many different ways of doing it... thanks everyone, that helped me a lot. Wish I could mark more correct/helpful answers. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 12:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Search-replace-with-special-characters-in-macro-variable/m-p/142917#M28616</guid>
      <dc:creator>titania</dc:creator>
      <dc:date>2014-01-23T12:58:52Z</dc:date>
    </item>
  </channel>
</rss>

