<?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: Sorting SAS Table with variable name as output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286313#M58697</link>
    <description>Hi Xia,&lt;BR /&gt;Thanks for your support.&lt;BR /&gt;I am trying this program on big data but now the problem is while defining array its not possible to write the column names like as you did in the following statement&lt;BR /&gt;array have{5} a1 s2 d3 f4 g5;&lt;BR /&gt;Now, in first test phase, columns are 100 and that too not in any particular order, could you suggest anything ??</description>
    <pubDate>Fri, 22 Jul 2016 02:59:43 GMT</pubDate>
    <dc:creator>deega</dc:creator>
    <dc:date>2016-07-22T02:59:43Z</dc:date>
    <item>
      <title>Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283671#M57812</link>
      <description>&lt;P&gt;I have the follwing table&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.56217&lt;/TD&gt;&lt;TD&gt;3.36783&lt;/TD&gt;&lt;TD&gt;3.53842&lt;/TD&gt;&lt;TD&gt;3.00214&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;s 2&lt;/TD&gt;&lt;TD&gt;2.56217&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.87413&lt;/TD&gt;&lt;TD&gt;4.1333&lt;/TD&gt;&lt;TD&gt;3.60389&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;d 3&lt;/TD&gt;&lt;TD&gt;3.36783&lt;/TD&gt;&lt;TD&gt;2.87413&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.46764&lt;/TD&gt;&lt;TD&gt;3.39893&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;f 4&lt;/TD&gt;&lt;TD&gt;3.53842&lt;/TD&gt;&lt;TD&gt;4.1333&lt;/TD&gt;&lt;TD&gt;2.46764&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.97952&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;g 5&lt;/TD&gt;&lt;TD&gt;3.00214&lt;/TD&gt;&lt;TD&gt;3.60389&lt;/TD&gt;&lt;TD&gt;3.39893&lt;/TD&gt;&lt;TD&gt;2.97952&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to sort this table rowwise(or may be columnwise) but instead of the observation value I need the variable name as output, something like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;id1&lt;/TD&gt;&lt;TD&gt;id2&lt;/TD&gt;&lt;TD&gt;id3&lt;/TD&gt;&lt;TD&gt;id4&lt;/TD&gt;&lt;TD&gt;id5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;s 2&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;d 3&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;f 4&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;g 5&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some more details:&lt;/P&gt;&lt;P&gt;Considering only the first row of the table&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.56217&lt;/TD&gt;&lt;TD&gt;3.36783&lt;/TD&gt;&lt;TD&gt;3.53842&lt;/TD&gt;&lt;TD&gt;3.00214&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorting It alonwith variable names&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.56217&lt;/TD&gt;&lt;TD&gt;3.36783&lt;/TD&gt;&lt;TD&gt;3.53842&lt;/TD&gt;&lt;TD&gt;3.00214&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Resulting into&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;2.56217&lt;/TD&gt;&lt;TD&gt;3.00214&lt;/TD&gt;&lt;TD&gt;3.36783&lt;/TD&gt;&lt;TD&gt;3.53842&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Now taking only the variable names&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a 1&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD&gt;s2&lt;/TD&gt;&lt;TD&gt;g5&lt;/TD&gt;&lt;TD&gt;d3&lt;/TD&gt;&lt;TD&gt;f4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Doing it for all the rows is my desired output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 05:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283671#M57812</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-12T05:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283675#M57815</link>
      <description>&lt;P&gt;that's one weird puzzle.&lt;/P&gt;
&lt;P&gt;why is d3 sometimes followed by f4 and sometimes by g5?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 04:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283675#M57815</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-12T04:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283676#M57816</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3.00214	3.60389	3.39893	2.97952	0
;
run;


proc transpose data=have out=temp;
by id notsorted;
run;
proc sort data=temp;
by id col1;
run;
proc transpose data=temp out=want(drop=_:) prefix=id;
by id;
var _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2016 05:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283676#M57816</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-12T05:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283677#M57817</link>
      <description>&lt;P&gt;Wow ! Its done in just few lines and I was thinking about a loop. Thanks a lot !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 05:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283677#M57817</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-12T05:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283679#M57819</link>
      <description>&lt;P&gt;Here is IML code , if you like it . It would be faster than PROC TRANSPOSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3.00214	3.60389	3.39893	2.97952	0
;
run;


proc iml;
use have;
read all var _num_ into x[c=vnames r=id];
close;

want=j(nrow(x),ncol(x),blankstr(nleng(vnames)));
do i=1 to nrow(x);
 temp=t(x[i,]);
 call sortndx(ndx,temp,1); 
 want[i,]=t(vnames[ndx]);
end;

names='id1':'id'+char(ncol(x));
create want from want[c=names r=id];
append from want[r=id];
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2016 05:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283679#M57819</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-12T05:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283686#M57825</link>
      <description>&lt;P&gt;Actually I have big data of around 200,0000 rows. This step will be in between the whole logic and the imput would be a square matrix of 200,0000 rows &amp;amp; columns. So what do you suggest in this suggestion. Transpose or IML ? Also could you advice some tutorial/ documentation which can help me in solving such things on my own ...?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283686#M57825</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-12T06:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283688#M57827</link>
      <description>&lt;P&gt;I would recommend to use IML, if you could make memory bigger by set option &amp;nbsp;-memsize 20G &amp;nbsp;in sasconfv9 file.&lt;/P&gt;
&lt;P&gt;If you don't have enough memory , try the following code could give you more fast .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3.00214	3.60389	3.39893	2.97952	0
;
run;


data want;
 set have;
 array temp{5};
 array have{5} a1	s2	d3	f4	g5;
 array id_{5} $ 32;
 do i=1 to dim(have);
  temp{i}=have{i};
 end;
 call sortn(of temp{*});
 do i=1 to dim(have);
  id_{i}=vname(have{whichn(temp{i},of have{*})});
 end;
 drop i temp: a1	s2	d3	f4	g5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2016 06:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283688#M57827</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-12T06:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283928#M57904</link>
      <description>&lt;P&gt;Hi, If there are duplicated value in an obs, my data step might not work for you .&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 00:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283928#M57904</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-13T00:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283938#M57908</link>
      <description>&lt;P&gt;Actually IML can handle BIG data .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3.00214	3.60389	3.39893	2.97952	0
a11	0	2.56217	3.36783	3.53842	3.00214
s12	2.56217	0	2.87413	4.1333	3.60389
d13	3.36783	2.87413	0	2.46764	3.39893
f14	3.53842	4.1333	2.46764	0	2.97952
g15	3.00214	3.60389	3.39893	2.97952	0
a21	0	2.56217	3.36783	3.53842	3.00214
s22	2.56217	0	2.87413	4.1333	3.60389
d23	3.36783	2.87413	0	2.46764	3.39893
f24	3.53842	4.1333	2.46764	0	2.97952
g25	3.00214	3.60389	3.39893	2.97952	0
;
run;



proc iml;
want=j(1,5,blankstr(32));
id=blankstr(32);
use have;
create want from want[c={ a1 s2 d3 f4 g5} r=id];

setin have;
setout want;

do data;
 read next var _num_ into x[c=vnames r=id];
 call sortndx(ndx,x`,1); 
 want=t(vnames[ndx]);
 
 append from want[r=id];
end;

close have want;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4028i61F83EB8C4579B6C/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 01:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283938#M57908</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-13T01:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283941#M57910</link>
      <description>&lt;P&gt;Thankyou Xia Keshan. It was a great help. However, it will take good amount of time in testing these codes on actual data, currently I am just trying on Dummy data. I dont know how feasible it will be on actual data, if required I will make clusters to reduce the data.&amp;nbsp;I will inform you which one finally works. I have used proc transpose but IML is new to me. I tried it once and the output was not coming in the form of SAS Table so I did not try the same. Is it possible to save&amp;nbsp;the output from IML in SAS table ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 01:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283941#M57910</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-13T01:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283951#M57915</link>
      <description>&lt;P&gt;Yes. That is what I am trying to do. Use the following code to save output into a SAS Table WANT .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create want from want;
append from want;
close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2016 02:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283951#M57915</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-13T02:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283960#M57918</link>
      <description>&lt;P&gt;HaHa, I found the following code could handle duplicate value as long as there are no missing value .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3	    3	3.39893	2.97952	0
;
run;


data want;
 set have;
 array have{5} a1	s2	d3	f4	g5;
 array id_{5} $ 32;
 do i=1 to dim(have);
  min=min(of have{*});
  idx=whichn(min,of have{*});
  id_{i}=vname(have{idx});
  have{idx}=.;
 end;
 drop idx min i a1 s2 d3 f4 g5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2016 03:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/283960#M57918</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-13T03:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286313#M58697</link>
      <description>Hi Xia,&lt;BR /&gt;Thanks for your support.&lt;BR /&gt;I am trying this program on big data but now the problem is while defining array its not possible to write the column names like as you did in the following statement&lt;BR /&gt;array have{5} a1 s2 d3 f4 g5;&lt;BR /&gt;Now, in first test phase, columns are 100 and that too not in any particular order, could you suggest anything ??</description>
      <pubDate>Fri, 22 Jul 2016 02:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286313#M58697</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-22T02:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286319#M58700</link>
      <description>&lt;PRE&gt;
Make a macro variable to hold these variables name .
OR you could try my IML code .



data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3	    3	3.39893	2.97952	0
;
run;
proc transpose data=have(obs=0) out=temp;
run;
proc sql noprint;
 select count(*) into : n from temp;
 select _name_ into : list separated by ' ' from temp;
quit;

data want;
 set have;
 array have{&amp;amp;n} &amp;amp;list ;
 array id_{&amp;amp;n} $ 32;
 do i=1 to dim(have);
  min=min(of have{*});
  idx=whichn(min,of have{*});
  id_{i}=vname(have{idx});
  have{idx}=.;
 end;
 keep id id_: ;
run;




&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2016 03:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286319#M58700</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-22T03:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286320#M58701</link>
      <description>&lt;P&gt;The double-dash syntax allows you to list all the variables in a table in the order they are stored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array have{*} a1 -- g5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data t; 
  a1=2; b2=3;z5=4; g5=1;
run;
data tt; 
  set t ;
  array have{*} a1 -- g5;
  put have[3]=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;z5=4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2016 03:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286320#M58701</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-22T03:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286324#M58703</link>
      <description>thanks !</description>
      <pubDate>Fri, 22 Jul 2016 04:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286324#M58703</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2016-07-22T04:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting SAS Table with variable name as output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286330#M58707</link>
      <description>&lt;PRE&gt;
If there was only one ID variables, That would be more simple.




data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3	    3	3.39893	2.97952	0
;
run;

%let dsid=%sysfunc(open(have));
%let nvars=%sysfunc(attrn(&amp;amp;dsid,nvars));
%let dsid=%sysfunc(close(&amp;amp;dsid));


data want;
 set have;
 array have{*} _numeric_;
 array id_{%eval(&amp;amp;nvars-1)} $ 32;
 do i=1 to dim(have);
  min=min(of have{*});
  idx=whichn(min,of have{*});
  id_{i}=vname(have{idx});
  have{idx}=.;
 end;
 keep id id_: ;
run;




&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2016 05:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-SAS-Table-with-variable-name-as-output/m-p/286330#M58707</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-22T05:36:48Z</dc:date>
    </item>
  </channel>
</rss>

