<?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: Sort list stored as comma separated string in macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207796#M38631</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would it help to sort earlier, before adding commas and parentheses?&amp;nbsp; That type of sorting (inefficient though it may be) has been around for a long time ... compare word1 with word2 and if the order is wrong, switch them.&amp;nbsp; Continue until there are no further changes to make.&amp;nbsp; If it would be useful, I can sketch it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Mar 2015 12:10:03 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-03-23T12:10:03Z</dc:date>
    <item>
      <title>Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207791#M38626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Hi All&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking for a way to sort a comma separated list stored in a macro variable. The sort needs to run as part of a "function style" macro. SAS version is 9.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;P&gt;%let var=(xx, aa, b);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;P&gt;%put var;&lt;/P&gt;&lt;P&gt;(aa,b,xx)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created a macro which creates a 32 character hex string using md5(). The purpose of this macro is to generate a primary key using a composite key as input.&lt;/P&gt;&lt;P&gt;I want that the generated key doesn't depend on the order in which the variable names get passed to the macro - though I need to sort the string with variable names before feeding it into the md5() function. It doesn't really matter how the string gets sorted as long as the algorithm returns always the same sort order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here how the real code looks like so far:&lt;/P&gt;&lt;P&gt;%macro eia_md5hex32/parmbuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %local _i _varname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let _i=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let _varname=%scan(&amp;amp;syspbuff,&amp;amp;_i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %str(put%(md5%(catq%(' ') &lt;/P&gt;&lt;P&gt;&amp;nbsp; %do %while(&amp;amp;_varname ne);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %str(,)&amp;amp;_varname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _i=%eval(&amp;amp;_i+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _varname=%scan(&amp;amp;syspbuff,&amp;amp;_i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %str(%)%), $hex32.%))&lt;/P&gt;&lt;P&gt;%mend ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; key1=%eia_md5hex32(age,'x',height);&lt;/P&gt;&lt;P&gt;&amp;nbsp; key2=%eia_md5hex32(height,'x',age);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key1=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key2=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is a sort which returns the same value for "key1" and "key2". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas of how to solve this or a full solution would be highly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Mar 2015 22:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207791#M38626</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-22T22:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207792#M38627</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 would suggest to sort the string before inputing it into the macro. For example you could use array sort function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;array temp(3) $ _temporary_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;str1=strip(put(age,best32.))||',x,'||strip(put(height,best32.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put str1;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(temp);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; temp{i}=scan(str1,i,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call sortc(of temp{*});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(temp);&lt;/P&gt;&lt;P&gt; if i=1 then str1=temp{1};&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; str1=strip(str1)||','||strip(temp{i});&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put str1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jakub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 09:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207792#M38627</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2015-03-23T09:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207793#M38628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &lt;A __default_attr="813260" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; but I need everything contained within a single function style macro. I need to be able to use the macro as if it were a SAS function (if you know SAS DI Studio: I want to use this macro in a DI expression).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've spent a bit more time working on a solution and I believe I was able to come up with some working code (I'll post it below). Not 100% happy with it and it would be great if somebody would have an idea of how to make this code simpler (as someone after me will have to understand and maintain it).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 10:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207793#M38628</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T10:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207794#M38629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below the code I was so far able to come up with. I believe it works but if there is a simpler solution then I would still be very interested to get it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro eia_md5hex32/parmbuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %local _i sorted_string;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* remove brackets from &amp;amp;syspbuff */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let syspbuff=%upcase(%sysfunc(prxchange(s/\(|\)//o,-1,%bquote(&amp;amp;syspbuff))));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* sort words from &amp;amp;syspbuff and store result in &amp;amp;sorted_string */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do %while(%scan(%bquote(&amp;amp;syspbuff),1,%bquote(,)) ne );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _min=%scan(%bquote(&amp;amp;syspbuff),1,%bquote(,));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do _i=2 %to %sysfunc(countw(%bquote(&amp;amp;syspbuff),%bquote(,)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _word=%scan(%bquote(&amp;amp;syspbuff),&amp;amp;_i,%bquote(,));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %bquote(&amp;amp;_min) &amp;gt; %bquote(&amp;amp;_word) %then %let _min=&amp;amp;_word;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let sorted_string=&amp;amp;sorted_string cats(&amp;amp;_min);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let syspbuff=%sysfunc(prxchange(s/&amp;amp;_min%str(,)?//o,-1,%bquote(&amp;amp;syspbuff)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* separate sorted words with commas */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let sorted_string=%sysfunc(prxchange(s/ +/%str(,)/o,-1,%bquote(&amp;amp;sorted_string)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* write SAS function creating md5() 32 character hex string */&lt;/P&gt;&lt;P&gt;&amp;nbsp; put(md5(catq(' ',&amp;amp;sorted_string)), $hex32.)&lt;/P&gt;&lt;P&gt;%mend ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; key1=%eia_md5hex32(age,'x',height);&lt;/P&gt;&lt;P&gt;&amp;nbsp; key2=%eia_md5hex32(height,'x',age);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key1=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key2=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 10:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207794#M38629</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T10:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207795#M38630</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;Sorry, have to agree with Jakub Chrenko here.&amp;nbsp; Your trying to write base SAS code in macro language.&amp;nbsp; It will cause you headaches if you go there, parmbuff could contain anything would be the first problem I see.&amp;nbsp; Also, not seeing what benefit you gain from this function:&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length var1-var3 $10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var1="zzz";&lt;/P&gt;&lt;P&gt;&amp;nbsp; var2="aa";&lt;/P&gt;&lt;P&gt;&amp;nbsp; var3="bb";&lt;/P&gt;&lt;P&gt;&amp;nbsp; array var{*} var1-var3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; call sortc(of var{*});&lt;/P&gt;&lt;P&gt;&amp;nbsp; tmp=md5(catx(',',of var{*}));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above uses the call sortc() function to re-arrange the var{*} into order,md5 is then called with the sorted array.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 11:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207795#M38630</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-23T11:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207796#M38631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would it help to sort earlier, before adding commas and parentheses?&amp;nbsp; That type of sorting (inefficient though it may be) has been around for a long time ... compare word1 with word2 and if the order is wrong, switch them.&amp;nbsp; Continue until there are no further changes to make.&amp;nbsp; If it would be useful, I can sketch it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 12:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207796#M38631</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-03-23T12:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207797#M38632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just call SORTC function with %SYSCALL.&amp;nbsp; You will have to put the comma separated listing into macro variables first but that won't be a problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a=5.6; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=x; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c=4.3;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sortc(a,b,c);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a=5.6; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=x; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c=4.3;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;A=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5.6&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; B=x C=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4.3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;34&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sortc(a,b,c);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;35&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: A=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4.3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; B=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5.6&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; C=x&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 12:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207797#M38632</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T12:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207798#M38633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or if the values are all numeric.&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a=5.16; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=10.01; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c=4.3;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sortn(a,b,c);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a=5.16; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=10.01; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c=4.3;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;A=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5.16&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; B=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10.01&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; C=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4.3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;34&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sortn(a,b,c);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;35&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=a &amp;amp;=b &amp;amp;=c;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: A=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4.3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; B=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5.16&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; C=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10.01&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 13:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207798#M38633</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T13:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207799#M38634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also remember you can also DOSUBL a bit of SAS PROC and/or DATA STEP code and still stay function style macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 13:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207799#M38634</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T13:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207800#M38635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Patrick ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I remember every question you posted here is not really easy . I know how good you were .&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;Maybe next time you should call SAS support firstly ? You know where they are .&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;%macro eia_md5hex32/parmbuff;&lt;/P&gt;&lt;P&gt; %let list=;&lt;/P&gt;&lt;P&gt; %let n=%sysfunc(countw( %bquote(&amp;amp;syspbuff) , %str(,) ));&lt;/P&gt;&lt;P&gt; %do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let a&amp;amp;i= %qscan(%bquote(&amp;amp;syspbuff),&amp;amp;i,%str(,%(%)) );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let list= &amp;amp;list.,a&amp;amp;i ;&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let list=%substr(%bquote(&amp;amp;list),2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %syscall sortc( &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;amp;list &lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put&amp;nbsp; &amp;amp;list&amp;nbsp; %bquote(&amp;amp;a1 &amp;amp;a2 &amp;amp;a3) ;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%eia_md5hex32(age,'x',height)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &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;171&lt;/P&gt;&lt;P&gt;172&amp;nbsp; %eia_md5hex32(age,'x',height)&lt;/P&gt;&lt;P&gt;a1,a2,a3&amp;nbsp; 'x' age height&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>Mon, 23 Mar 2015 13:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207800#M38635</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-03-23T13:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207801#M38636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Combine it into data step :&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;&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;%macro eia_md5hex32/parmbuff;&lt;/P&gt;&lt;P&gt;%let list=;&lt;/P&gt;&lt;P&gt;%let n=%sysfunc(countw( %bquote(&amp;amp;syspbuff) , %str(,) ));&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let a&amp;amp;i= %qscan(%bquote(&amp;amp;syspbuff),&amp;amp;i,%str(,%(%)) );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let list= &amp;amp;list.,a&amp;amp;i ;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let list=%substr(%bquote(&amp;amp;list),2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %syscall sortc(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;amp;list&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put&amp;nbsp; &amp;amp;list&amp;nbsp; %bquote(&amp;amp;a1 &amp;amp;a2 &amp;amp;a3) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %global sorted_string;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let sorted_string=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=1 %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let sorted_string= &amp;amp;sorted_string.%bquote(&amp;amp;&amp;amp;a&amp;amp;i) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put sorted_string: %bquote(&amp;amp;sorted_string) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put(md5(symget('sorted_string')), $hex32.)&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; key1=%eia_md5hex32(age,'x',height);&lt;/P&gt;&lt;P&gt;&amp;nbsp; key2=%eia_md5hex32(height,'x',age);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key1=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put key2=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 14:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207801#M38636</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-03-23T14:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207802#M38637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would it be a good idea to add %LOCAL to insure those variables you're creating don't escape and cause havoc?&amp;nbsp; Would &lt;A __default_attr="12296" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; know to do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 14:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207802#M38637</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T14:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207803#M38638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So combining the ideas posted is sounds like you want a utility macro that will take as input a list of variable names and return the same names in sorted order.&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: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;sort_names&lt;/EM&gt;&lt;/STRONG&gt; /parmbuff;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; i n names result sep;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; n=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(countw(&amp;amp;syspbuff,(, )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; v&amp;amp;i=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%upcase&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(&amp;amp;syspbuff,&amp;amp;i,(, )));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; names=&amp;amp;names.&amp;amp;sep.v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sep=,;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sortc(&amp;amp;names);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sep=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; result=&amp;amp;result.&amp;amp;sep.&amp;amp;&amp;amp;v&amp;amp;i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sep=,;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; 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: 'Courier New'; color: black; background: white;"&gt;&amp;amp;result&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: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; 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: 'Courier New'; 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: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; %sort_names(a,B,C);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; %sort_names(x1, x2 ,B,C);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; 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: 'Courier New'; color: black; background: white;"&gt;You could then use that as input to CATX() or other functions to generate you unique string.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&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: 'Courier New';"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; key1=catx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'|'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,%&lt;STRONG&gt;&lt;EM&gt;sort_names&lt;/EM&gt;&lt;/STRONG&gt;(age,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'x'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,height));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; key2=catx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'|'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,%&lt;STRONG&gt;&lt;EM&gt;sort_names&lt;/EM&gt;&lt;/STRONG&gt;(height,age,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'x'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; key1= / key2= ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;stop&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; 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: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;key1=X|14|69&lt;/P&gt;&lt;P&gt;key2=X|14|69&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 16:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207803#M38638</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-03-23T16:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207804#M38639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is also one of methods.&lt;/P&gt;&lt;P&gt;%macro sort_names/parmbuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; filename clip clipbrd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file clip dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put "&amp;amp;syspbuff";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; data vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile clip dlm=',';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input name $ @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; name=compress(name,'()');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select name into:result separated by ',' from vars order by name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let result=(&amp;amp;result);&lt;/P&gt;&lt;P&gt; %mend;&lt;/P&gt;&lt;P&gt;%put %sort_names(x,a,d);&lt;/P&gt;&lt;P&gt;%put %sort_names(x1, x2 ,B,C);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 19:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207804#M38639</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-03-23T19:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207805#M38640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="814511" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As already replied to Jakub: I need it fully function style as I want to use this macro like a SAS function in a SAS DI Studio Expression.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9707_Capture.PNG" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207805#M38640</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T21:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207806#M38641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Yes, I believe this is it. I've tried using sortc() but didn't realize that I need to reference the variables in the function without ampersand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207806#M38641</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T21:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207807#M38642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="468858" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Yes, he would.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207807#M38642</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T21:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207808#M38643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The "thing" with call routines is that the alter the values of variables, in this case macro variables.&amp;nbsp; I usually forget and try to use constants too or include the &amp;amp; with the macro variable, causes all sorts of problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207808#M38643</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T21:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207809#M38644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I see, I've looked back at your original post and see that you did include %LOCAL.&amp;nbsp; I don't think you would need to use _ as first character unless you just like that.&amp;nbsp; I usually save the underscores for data steps where I want to use names that I am reasonably sure won't exist in the users data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207809#M38644</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-23T21:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sort list stored as comma separated string in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207810#M38645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your solution. That's very helpful. &lt;/P&gt;&lt;P&gt;Why should I throw such a question at SAS TechSupport. There is a bunch of very capable people here in these forums - and these forums are here to ask others for help and to help others.&lt;/P&gt;&lt;P&gt;SAS TechSupport's role is imho primarily for support with technical issues and not for programming/usage questions (the lines are blurred, but still...).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-list-stored-as-comma-separated-string-in-macro-variable/m-p/207810#M38645</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-23T21:40:13Z</dc:date>
    </item>
  </channel>
</rss>

