<?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: How to convert a list into a prefixed list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160345#M31225</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;I don't quite understand what the following is doing:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; &lt;STRONG&gt;&lt;EM&gt;newlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;* convert oldlist to newlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%if&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; (&amp;amp;__iter__) gt &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;1&lt;/SPAN&gt; &lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%then&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;(,);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: #0000c0; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&amp;amp;word&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; &lt;STRONG&gt;&lt;EM&gt;oldlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;* convert newlist to oldlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%scan&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;(&amp;amp;word,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;What is the purpose of the above for using %loop()?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;What does "&amp;amp;" mean in %put &amp;amp;=newlist?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Nov 2014 04:36:40 GMT</pubDate>
    <dc:creator>Macro</dc:creator>
    <dc:date>2014-11-07T04:36:40Z</dc:date>
    <item>
      <title>How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160337#M31217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a varlist given by&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let varlist=%str(var1, var2, var3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In practice, there may be 100 such variables in the list instead of just three.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to convert the above macro variable varlist into something like&lt;/P&gt;&lt;P&gt;newvarlist =a.var1, a.var2, a.var3&lt;/P&gt;&lt;P&gt;efficiently ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 21:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160337#M31217</guid>
      <dc:creator>Macro</dc:creator>
      <dc:date>2014-11-06T21:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160338#M31218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The above varlist can also be varlist=var1 var2 var3, but the newvarlist must be a.var1, a.var2, a.var3 separated by comma.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 21:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160338#M31218</guid>
      <dc:creator>Macro</dc:creator>
      <dc:date>2014-11-06T21:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160339#M31219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure there are numerous ways to accomplish what you want. Here is one way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let varlist=%str(var1, var2, var3);&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length newvarlist $32767.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while (scan("&amp;amp;varlist,",i," ,") ne "");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvarlist=catx(', ',newvarlist,'a.'||scan("&amp;amp;varlist,",i," ,"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symput('newvarlist',newvarlist);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;newvarlist;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 22:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160339#M31219</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-11-06T22:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160340#M31220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is a true representation of the variable names you are using you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET VARLIST=%SYSFUNC(TRANWRD(%STR(VAR1, VAR2, VAR3),VAR,A.VAR));&lt;/P&gt;&lt;P&gt;%PUT *************************** &amp;amp;VARLIST.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 22:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160340#M31220</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2014-11-06T22:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160341#M31221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it with a loop, but if the input is well formed then TRANWRD will work also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%let list=x y z ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;%let newlist=A.%sysfunc(tranwrd(&amp;amp;list,%str( ),%str( A.))) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is not well behaved you can clean it up with %SYSFUNC(COMPBL()) for space delimited lists.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 22:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160341#M31221</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-11-06T22:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160342#M31222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Download Richard Devenezia's seplist macro:&amp;nbsp; &lt;A href="http://www.devenezia.com/downloads/sas/macros/index.php?m=seplist" title="http://www.devenezia.com/downloads/sas/macros/index.php?m=seplist"&gt;http://www.devenezia.com/downloads/sas/macros/index.php?m=seplist&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or, download my slightly modified version:&amp;nbsp; &lt;A href="https://github.com/scottbass/SAS/blob/master/Macro/seplist.sas" title="https://github.com/scottbass/SAS/blob/master/Macro/seplist.sas"&gt;SAS/seplist.sas at master · scottbass/SAS · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also download my loop macro from my GitHub site&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lots of good macros on both sites &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;P&gt;&lt;/P&gt;&lt;P&gt;Then, you can do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; varlist=&lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(var1, var2, var3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%put&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; %seplist(&lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%superq&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(varlist),indlm=&lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(,),prefix=a.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* I hate commas in a macro variable list. That's why I have to use %superq above.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* Don't use them, let %seplist add them later at "run time" ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; varlist=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;var1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;var2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;var3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; newlist = %seplist(&amp;amp;varlist,prefix=a.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%put&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;=newlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* Or, use %loop, which is more complex, but can convert both ways ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;newlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* convert oldlist to newlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%if&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; (&amp;amp;__iter__) gt &lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;1&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%then&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(,);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: #0000c0; background: white;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;&amp;amp;word&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;oldlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: teal; background: white;"&gt;* convert newlist to oldlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%scan&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(&amp;amp;word,&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: blue; background: white;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: #A0C0FF;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; varlist=varA varB varC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; newlist = %loop(&amp;amp;varlist,mname=newlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%put&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;=newlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; oldlist = %loop(&lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%superq&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(newlist),dlm=&lt;/SPAN&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt;(,),mname=oldlist);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 11.0pt; font-family: 'SAS Monospace';"&gt;&lt;STRONG&gt;%put&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'SAS Monospace'; color: black; background: white;"&gt; &amp;amp;=oldlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; %let varlist=%str(var1, var2, var3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; %put %seplist(%superq(varlist),indlm=%str(,),prefix=a.);&lt;/P&gt;&lt;P&gt;a.var1,a.var2,a.var3&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp; * I hate commas in a macro variable list. ;&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; * Don't use them, let %seplist add them later at "run time" ;&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp; %let varlist=&lt;/P&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp; var1&lt;/P&gt;&lt;P&gt;11&amp;nbsp;&amp;nbsp; var2&lt;/P&gt;&lt;P&gt;12&amp;nbsp;&amp;nbsp; var3&lt;/P&gt;&lt;P&gt;13&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;14&amp;nbsp;&amp;nbsp; %let newlist = %seplist(&amp;amp;varlist,prefix=a.);&lt;/P&gt;&lt;P&gt;15&amp;nbsp;&amp;nbsp; %put &amp;amp;=newlist;&lt;/P&gt;&lt;P&gt;NEWLIST=a.var1,a.var2,a.var3&lt;/P&gt;&lt;P&gt;16&lt;/P&gt;&lt;P&gt;17&amp;nbsp;&amp;nbsp; * Or, use %loop, which is more complex, but can convert both ways ;&lt;/P&gt;&lt;P&gt;18&amp;nbsp;&amp;nbsp; %macro newlist;&lt;/P&gt;&lt;P&gt;19&amp;nbsp;&amp;nbsp; %* convert oldlist to newlist ;&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp; %if (&amp;amp;__iter__) gt 1 %then ,;&lt;/P&gt;&lt;P&gt;21&amp;nbsp;&amp;nbsp; a.&amp;amp;word&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp; %mend;&lt;/P&gt;&lt;P&gt;23&amp;nbsp;&amp;nbsp; %macro oldlist;&lt;/P&gt;&lt;P&gt;24&amp;nbsp;&amp;nbsp; %* convert newlist to oldlist ;&lt;/P&gt;&lt;P&gt;25&amp;nbsp;&amp;nbsp; %scan(&amp;amp;word,2,.)&lt;/P&gt;&lt;P&gt;26&amp;nbsp;&amp;nbsp; %mend;&lt;/P&gt;&lt;P&gt;27&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp; %let varlist=varA varB varC;&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp; %let newlist = %loop(&amp;amp;varlist,mname=newlist);&lt;/P&gt;&lt;P&gt;30&amp;nbsp;&amp;nbsp; %put &amp;amp;=newlist;&lt;/P&gt;&lt;P&gt;NEWLIST=a.varA , a.varB , a.varC&lt;/P&gt;&lt;P&gt;31&lt;/P&gt;&lt;P&gt;32&amp;nbsp;&amp;nbsp; %let oldlist = %loop(%superq(newlist),dlm=%str(,),mname=oldlist);&lt;/P&gt;&lt;P&gt;33&amp;nbsp;&amp;nbsp; %put &amp;amp;=oldlist;&lt;/P&gt;&lt;P&gt;OLDLIST=varA varB varC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would just use %seplist unless I needed to convert back to the original list and for some reason didn't preserve the original list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%seplist is REALLY handy for converting between data step and SQL syntax.&amp;nbsp; I used it ALL the time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 03:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160342#M31222</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2014-11-07T03:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160343#M31223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;very cute catx() function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 03:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160343#M31223</guid>
      <dc:creator>Macro</dc:creator>
      <dc:date>2014-11-07T03:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160344#M31224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice stuff !!! Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 04:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160344#M31224</guid>
      <dc:creator>Macro</dc:creator>
      <dc:date>2014-11-07T04:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160345#M31225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;I don't quite understand what the following is doing:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; &lt;STRONG&gt;&lt;EM&gt;newlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;* convert oldlist to newlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%if&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; (&amp;amp;__iter__) gt &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;1&lt;/SPAN&gt; &lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%then&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%str&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;(,);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: #0000c0; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&amp;amp;word&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%macro&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt; &lt;STRONG&gt;&lt;EM&gt;oldlist&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="background: white; color: teal; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;* convert newlist to oldlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: navy; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;&lt;STRONG&gt;%scan&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;(&amp;amp;word,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #a0c0ff; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;%mend&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;What is the purpose of the above for using %loop()?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: 'SAS Monospace'; font-size: 11pt;"&gt;What does "&amp;amp;" mean in %put &amp;amp;=newlist?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 04:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160345#M31225</guid>
      <dc:creator>Macro</dc:creator>
      <dc:date>2014-11-07T04:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160346#M31226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or you don't need &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt; %SYSFUNC(COMPBL()) for &lt;/SPAN&gt; multiple blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let list=x&amp;nbsp;&amp;nbsp;&amp;nbsp; y&amp;nbsp;&amp;nbsp;&amp;nbsp; z ;&lt;/P&gt;&lt;P&gt;%let newlist=a.%sysfunc(prxchange(s/\s+/%str(,a.)/,-1,&amp;amp;list));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;newlist ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 13:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160346#M31226</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-07T13:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a list into a prefixed list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160347#M31227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read the macro headers, including the numerous use cases.&lt;/P&gt;&lt;P&gt;Read the SAS 9.3 (or 9.4) documentation on the %put macro statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Post back then if you still have questions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 23:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-list-into-a-prefixed-list/m-p/160347#M31227</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2014-11-07T23:38:43Z</dc:date>
    </item>
  </channel>
</rss>

