<?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: Do not want DB to sort the data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311353#M67271</link>
    <description>&lt;P&gt;Yes I can do that. But I have many such data step so I would end up writing too many code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will go by this solution, if there are none.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Nov 2016 09:18:52 GMT</pubDate>
    <dc:creator>RahulG</dc:creator>
    <dc:date>2016-11-14T09:18:52Z</dc:date>
    <item>
      <title>Do not want DB to sort the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311322#M67255</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have DB table and want to use in SAS server. I need sorted data then I can use by statement in data step to skip sorting.&lt;/P&gt;&lt;P&gt;Ex&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;set DB.sample;&lt;/P&gt;&lt;P&gt;by Id ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For more detail, You can refer to this post&amp;nbsp;&lt;/P&gt;&lt;P&gt;With reference to this post&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2016/02/04/avoid-sorting-data-in-sas/" target="_blank"&gt;http://blogs.sas.com/content/sasdummy/2016/02/04/avoid-sorting-data-in-sas/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is to sort on SAS server and I do not want DB server to sort the data. Reason is DB server and SAS server are sorting based on different language. What option should I provide so that sorting in DB can be stopped.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 05:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311322#M67255</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-11-14T05:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Do not want DB to sort the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311338#M67264</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=db.sample
  out=sample
;
by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that does not prevent the wrong sort (as SAS might pass off some of the work to the DB), do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
set db.sample;
run;

proc sort data=sample;
by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Nov 2016 07:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311338#M67264</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-14T07:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Do not want DB to sort the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311353#M67271</link>
      <description>&lt;P&gt;Yes I can do that. But I have many such data step so I would end up writing too many code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will go by this solution, if there are none.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 09:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311353#M67271</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-11-14T09:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Do not want DB to sort the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311361#M67276</link>
      <description>&lt;P&gt;If you want that the work will be done in the SAS server, then you need bring your data to it.&lt;/P&gt;
&lt;P&gt;As you need many DB tables, in order to downsize the SAS code, use a macro to do the work&lt;/P&gt;
&lt;P&gt;and supply it an argumnt of table names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I shall use first code presented by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser﻿&lt;/a&gt;, but you can change the inner code to any desired one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%macro get_db(tables);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let no_of_tables = %sysfunc(countw(&amp;amp;tables));&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %do i=1 %to &amp;amp;no_of_tables;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let tb_name = %scan(&amp;amp;tables, &amp;amp;i);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sort &lt;/SPAN&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;db&lt;SPAN class="token punctuation"&gt;.&lt;STRONG&gt;&amp;amp;tb_name  &lt;/STRONG&gt;&lt;/SPAN&gt;out&lt;SPAN class="token operator"&gt;=&amp;amp;tb_name ;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;  by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%mend get_db;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%get_db(&lt;/STRONG&gt;sample1 sample2 sample3 ...&amp;nbsp;&lt;STRONG&gt;);&lt;/STRONG&gt; &amp;nbsp;/* enter DB tables you need */&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 10:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311361#M67276</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-14T10:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Do not want DB to sort the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311386#M67283</link>
      <description>&lt;P&gt;Perhaps the SORTPGM=SAS system option might be what you are looking for?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 12:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-not-want-DB-to-sort-the-data/m-p/311386#M67283</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-11-14T12:47:18Z</dc:date>
    </item>
  </channel>
</rss>

