<?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: WHERE statement in a MERGE statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481375#M124507</link>
    <description>&lt;P&gt;There are a few mistakes here:&lt;/P&gt;
&lt;P&gt;1) missing quote from after 201806 in both instances&lt;/P&gt;
&lt;P&gt;2) month (numeric) cannot be within a string&lt;/P&gt;
&lt;P&gt;3) month (number 1-12) cannot be within a 2 year gap - which would need to know year.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jul 2018 07:50:54 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-07-26T07:50:54Z</dc:date>
    <item>
      <title>WHERE statement in a MERGE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481368#M124500</link>
      <description>&lt;P&gt;Hey Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem, I want to merge 2 sas tables with some WHERE restrictions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data merged;&lt;/P&gt;&lt;P&gt;merge table1 (in=a (...) where=(month=""))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table2(in=b (...) where=(month between "201706" and "201806 or last_month between "201706 and "201806"&amp;nbsp;&amp;nbsp;and not&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;anyalpha(PERSONAL_ID)));&lt;/P&gt;&lt;P&gt;by personal_id;&lt;/P&gt;&lt;P&gt;(...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somehow, the code doesn't get the anyalpha statement and thus can't merge the two tables. I think more work needs to be done within the second WHERE statement but not sure how to solve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I sort out the IDs with alpha characters in a data step before the merger, it works out. But not within the merge statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481368#M124500</guid>
      <dc:creator>NilsNoh</dc:creator>
      <dc:date>2018-07-26T07:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement in a MERGE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481371#M124503</link>
      <description>&lt;P&gt;As posted, your second where= dataset option has a problem because of missing quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post some example data (data steps with datalines) that illustrate your issue (unless solving the missing quotes problem also solves your issue).&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481371#M124503</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-26T07:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement in a MERGE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481375#M124507</link>
      <description>&lt;P&gt;There are a few mistakes here:&lt;/P&gt;
&lt;P&gt;1) missing quote from after 201806 in both instances&lt;/P&gt;
&lt;P&gt;2) month (numeric) cannot be within a string&lt;/P&gt;
&lt;P&gt;3) month (number 1-12) cannot be within a 2 year gap - which would need to know year.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-statement-in-a-MERGE-statement/m-p/481375#M124507</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-07-26T07:50:54Z</dc:date>
    </item>
  </channel>
</rss>

