<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415954#M102112</link>
    <description>&lt;P&gt;what you think about this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%Macro&lt;/FONT&gt; VR(data, sort);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; proc sort data=&amp;amp;data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by &amp;amp;sort;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; run;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%mend&lt;/FONT&gt; vr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data rm;&lt;BR /&gt;&amp;nbsp; &lt;FONT color="#0000FF"&gt;length&lt;/FONT&gt; macro $100;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set sashelp.vtable;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;FONT color="#0000FF"&gt;where&lt;/FONT&gt; libname=&lt;FONT color="#FF00FF"&gt;"WORK"&lt;/FONT&gt; and memname ~in(&lt;FONT color="#FF00FF"&gt;"_SV", "__MVALLRAW"&lt;/FONT&gt;);;&lt;BR /&gt;macro=&lt;FONT color="#FF00FF"&gt;'%VR(' &lt;/FONT&gt;|| strip(memname) || &lt;FONT color="#FF00FF"&gt;", _PATIENT_DISPLAY_ID_FULL"&lt;/FONT&gt; || &lt;FONT color="#FF00FF"&gt;");"&lt;/FONT&gt;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;%macro&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#333333"&gt; VV;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select macro into:macro separated by &lt;FONT color="#FF00FF"&gt;" "&lt;/FONT&gt; from rm;&lt;BR /&gt;quit;&lt;BR /&gt;&amp;amp;macro;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;%mend&lt;/FONT&gt; VV;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#333333"&gt;%VV;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Nov 2017 09:13:43 GMT</pubDate>
    <dc:creator>Vahe_Mar</dc:creator>
    <dc:date>2017-11-24T09:13:43Z</dc:date>
    <item>
      <title>SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415941#M102102</link>
      <description>&lt;P&gt;Hi, how can I sort more then 2 datas same time by one variable which available in every data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 07:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415941#M102102</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2017-11-24T07:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415945#M102105</link>
      <description>&lt;P&gt;Assuming you mean datasets (and that they have the same structure), you can do this by creating a view and sorting that - eg:&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 one;
  x=1;y=2; output;
  x=1;y=3; output;
data two;
  x=4;y=6; output;
  x=0;y=7; output;
data sortview /view=sortview;
  set one two;
proc sort data=sortview out=final;
  by x;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 08:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415945#M102105</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2017-11-24T08:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415947#M102107</link>
      <description>&lt;P&gt;Hi Allan Bowe, I mean all datas have same variable and need to sort before set&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 08:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415947#M102107</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2017-11-24T08:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415952#M102110</link>
      <description>&lt;P&gt;ok - I'm going to assume you didn't necessarily mean that the datasets had to be sorted at the same time (which is possible, using rsubmit or other techniques).&amp;nbsp; If you are happy for the datasets to be sorted in sequence, here is a simple macro solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
x=1;y=2; output;
x=1;y=3; output;
data two;
x=4;y=6; output;
x=0;y=7; output;
data three;
x=6;y=6; output;
x=6;y=7; output;

%macro sortandappend(datasets=,var=x,outds=outds);
%local i;
%do i=1 %to %sysfunc(countw(&amp;amp;datasets));
  %let ds=%scan(&amp;amp;datasets,&amp;amp;i);
  proc sort data=&amp;amp;ds;
    by &amp;amp;var;
  run;
%end;
data &amp;amp;outds;
  set &amp;amp;datasets;
run;
%mend;

%sortandappend(datasets=one two three,var=x,outds=outds)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You provide a list of input datasets to the macro (one, two and three), set the variable to sort by, and the dataset to create.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415952#M102110</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2017-11-24T09:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415954#M102112</link>
      <description>&lt;P&gt;what you think about this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%Macro&lt;/FONT&gt; VR(data, sort);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; proc sort data=&amp;amp;data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by &amp;amp;sort;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; run;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;%mend&lt;/FONT&gt; vr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data rm;&lt;BR /&gt;&amp;nbsp; &lt;FONT color="#0000FF"&gt;length&lt;/FONT&gt; macro $100;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set sashelp.vtable;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;FONT color="#0000FF"&gt;where&lt;/FONT&gt; libname=&lt;FONT color="#FF00FF"&gt;"WORK"&lt;/FONT&gt; and memname ~in(&lt;FONT color="#FF00FF"&gt;"_SV", "__MVALLRAW"&lt;/FONT&gt;);;&lt;BR /&gt;macro=&lt;FONT color="#FF00FF"&gt;'%VR(' &lt;/FONT&gt;|| strip(memname) || &lt;FONT color="#FF00FF"&gt;", _PATIENT_DISPLAY_ID_FULL"&lt;/FONT&gt; || &lt;FONT color="#FF00FF"&gt;");"&lt;/FONT&gt;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;%macro&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#333333"&gt; VV;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select macro into:macro separated by &lt;FONT color="#FF00FF"&gt;" "&lt;/FONT&gt; from rm;&lt;BR /&gt;quit;&lt;BR /&gt;&amp;amp;macro;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;%mend&lt;/FONT&gt; VV;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#333333"&gt;%VV;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415954#M102112</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2017-11-24T09:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415961#M102114</link>
      <description>&lt;P&gt;You can call the %vr macro with call execute() from the data step, the second macro is not needed.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415961#M102114</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-24T09:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415962#M102115</link>
      <description>without second macro i have errors about "by"</description>
      <pubDate>Fri, 24 Nov 2017 09:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415962#M102115</guid>
      <dc:creator>Vahe_Mar</dc:creator>
      <dc:date>2017-11-24T09:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: SORTING</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415967#M102119</link>
      <description>&lt;P&gt;Your not really providing any information.&amp;nbsp; What datasets do you mean, do they have a common name, like ds1 ds2 which we can use, will they all have different names, is it all datasets in a given library?&amp;nbsp; If its all in a library then:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="YOURLIB"));
  call execute(cats('proc sort data=yourlib.',memname,'; by var1; run;'));
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SORTING/m-p/415967#M102119</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-24T09:29:11Z</dc:date>
    </item>
  </channel>
</rss>

