<?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: MERGE equivalent in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465987#M118880</link>
    <description>&lt;P&gt;Datastep merge requires that both datasets are sorted by the by variables.&amp;nbsp; This is a hard and fixed rule.&amp;nbsp; There is nothing stopping you making a copy of the datasets, sorting and merging those.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other alternatives include using a proc sql code block and rewrite the code you have to be base ANSI, maybe something like:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as 
  select  a.var1,
          case when b.value1 ne "" then b.value1 else a.value1 end as value1
  from    tablea a
  left join tableb b
  on       a.var1=b.var1;
quit;&lt;/PRE&gt;
&lt;P&gt;This still of course does the sorts, its just implicit in the SQL parser to do this rather than you writing the code.&lt;/P&gt;
&lt;P&gt;Another way could be hash table, not yet had a reason to use these, so look up some of the plenty of examples on the web or here.&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2018 12:48:39 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-05-30T12:48:39Z</dc:date>
    <item>
      <title>MERGE equivalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465932#M118858</link>
      <description>Can anyone help me with the SAS equivalent of following code&lt;BR /&gt;MERGE TABLE A USING&lt;BR /&gt;(SELECT VAR1,VALUE1 FROM TABLE B) C&lt;BR /&gt;ON C.VAR1=A.VAR1 WHEN MATCHED THEN UPDATE&lt;BR /&gt;SET A.VALUE1= C.VALUE1</description>
      <pubDate>Wed, 30 May 2018 07:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465932#M118858</guid>
      <dc:creator>FLINT</dc:creator>
      <dc:date>2018-05-30T07:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE equivalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465937#M118861</link>
      <description>&lt;P&gt;Something like (nothing to check with):&lt;/P&gt;
&lt;PRE&gt;data want (drop=val1);
  merge tablea (in=a) tableb (in=b keep=var1,value1 rename=(value1=val1));
  by var1;
  if a and b then value1=val1;
run;&lt;/PRE&gt;
&lt;P&gt;Do be aware that both tablea and b both need to be sorted by var1 beforehand.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 08:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465937#M118861</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-30T08:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE equivalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465948#M118864</link>
      <description>Here the issue is that I cannot sort one of the tables as its a production table</description>
      <pubDate>Wed, 30 May 2018 09:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465948#M118864</guid>
      <dc:creator>FLINT</dc:creator>
      <dc:date>2018-05-30T09:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE equivalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465950#M118866</link>
      <description>&lt;P&gt;Then sort it to an intermediary in WORK and use that for the merge.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212379"&gt;@FLINT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Here the issue is that I cannot sort one of the tables as its a production table&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 10:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465950#M118866</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-30T10:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE equivalent in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465987#M118880</link>
      <description>&lt;P&gt;Datastep merge requires that both datasets are sorted by the by variables.&amp;nbsp; This is a hard and fixed rule.&amp;nbsp; There is nothing stopping you making a copy of the datasets, sorting and merging those.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other alternatives include using a proc sql code block and rewrite the code you have to be base ANSI, maybe something like:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as 
  select  a.var1,
          case when b.value1 ne "" then b.value1 else a.value1 end as value1
  from    tablea a
  left join tableb b
  on       a.var1=b.var1;
quit;&lt;/PRE&gt;
&lt;P&gt;This still of course does the sorts, its just implicit in the SQL parser to do this rather than you writing the code.&lt;/P&gt;
&lt;P&gt;Another way could be hash table, not yet had a reason to use these, so look up some of the plenty of examples on the web or here.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 12:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-equivalent-in-SAS/m-p/465987#M118880</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-30T12:48:39Z</dc:date>
    </item>
  </channel>
</rss>

