<?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 Is it a must to do proc sort right before merging dataset using data step MERGE? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709497#M218186</link>
    <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;It is quite a basic question regarding merging data. But normally we may prefer using "PROC SORT with data step MERGE" to merge two or more datasets instead of using JOIN in PROC SQL, especially when it comes to huge data (cartesian join).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is whether we MUST PROC SORT right before we do MERGE, or we can PROC SORT previously, and we run some procedures, then we come back to MERGE without PROC SORT again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mean it is no harm to write a PROC SORT statement (even I deem that we can write a short macro to sort all datasets at one time) , but just of curiosity regarding parsimony thingamajig.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I PROC SORT files A,B,C by Type, then I transpose file A,B, C by Type, then I merge them together, whether I should PROC SORT AGAIN before merging or it is not a need because I already merged before transposing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Tue, 05 Jan 2021 20:40:45 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-01-05T20:40:45Z</dc:date>
    <item>
      <title>Is it a must to do proc sort right before merging dataset using data step MERGE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709497#M218186</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;It is quite a basic question regarding merging data. But normally we may prefer using "PROC SORT with data step MERGE" to merge two or more datasets instead of using JOIN in PROC SQL, especially when it comes to huge data (cartesian join).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is whether we MUST PROC SORT right before we do MERGE, or we can PROC SORT previously, and we run some procedures, then we come back to MERGE without PROC SORT again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mean it is no harm to write a PROC SORT statement (even I deem that we can write a short macro to sort all datasets at one time) , but just of curiosity regarding parsimony thingamajig.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I PROC SORT files A,B,C by Type, then I transpose file A,B, C by Type, then I merge them together, whether I should PROC SORT AGAIN before merging or it is not a need because I already merged before transposing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Jan 2021 20:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709497#M218186</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-05T20:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is it a must to do proc sort right before merging dataset using data step MERGE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709504#M218188</link>
      <description>&lt;P&gt;There is no need to run PROC SORT if you KNOW the data is sorted in the way you need (or it has an INDEX that can be used).&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 21:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709504#M218188</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-05T21:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is it a must to do proc sort right before merging dataset using data step MERGE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709505#M218189</link>
      <description>&lt;P&gt;Whether or not you need a sort before a merge is something the programmer has to decide, based on knowledge of what the program is doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data was sorted way up at the beginning of the program, and then you run a bunch of procedures that don't change the order of the data, then there's no need to sort again before a data step merge.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 21:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-a-must-to-do-proc-sort-right-before-merging-dataset-using/m-p/709505#M218189</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-05T21:13:05Z</dc:date>
    </item>
  </channel>
</rss>

