<?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 Merging document with proc SQL or other procedure in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270750#M53839</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I always merge tables with the following method which require me to sort both tables by BY field. Is there a better way where I don't have to sort the table before merging?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I had been doing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA Want;&lt;BR /&gt;MERGE have1(in=a) 2ave2(in=b);&lt;BR /&gt; BY common_variable;&lt;BR /&gt; IF a=1;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2016 19:30:27 GMT</pubDate>
    <dc:creator>mlogan</dc:creator>
    <dc:date>2016-05-16T19:30:27Z</dc:date>
    <item>
      <title>Merging document with proc SQL or other procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270750#M53839</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I always merge tables with the following method which require me to sort both tables by BY field. Is there a better way where I don't have to sort the table before merging?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I had been doing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA Want;&lt;BR /&gt;MERGE have1(in=a) 2ave2(in=b);&lt;BR /&gt; BY common_variable;&lt;BR /&gt; IF a=1;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 19:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270750#M53839</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-16T19:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Merging document with proc SQL or other procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270773#M53845</link>
      <description>&lt;P&gt;The most common replacement would be a SQL left join.&amp;nbsp; Here's a paper that talks about more variations than you might want to see:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi30/249-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/249-30.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other, more complex methods, including creating an index, hashing, creating a format.&amp;nbsp; But SQL would definitely the place to begin.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are concerned about getting identical results to the MERGE, you have to consider whether any data sets might have more than one observation per value of COMMON_VARIABLE.&amp;nbsp; If both data sets might have more than one, you have to ask yourself what the result should be ... not an easy topic.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 19:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270773#M53845</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-16T19:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merging document with proc SQL or other procedure</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270775#M53846</link>
      <description>&lt;P&gt;You could do the same thing in SQL. Behind the scenes SQL still sorts your data but you avoid having to sort it yourself. SQL isn't necessarrily better, just different:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as 
  select *
  from have1 as a
  left join have2 as b
  on a.common_variable = b.common_variable;
  ;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 19:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-document-with-proc-SQL-or-other-procedure/m-p/270775#M53846</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-05-16T19:56:51Z</dc:date>
    </item>
  </channel>
</rss>

