<?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 Condition Advice in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304224#M64744</link>
    <description>Ok, I will try this. Ty.</description>
    <pubDate>Thu, 13 Oct 2016 02:41:49 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2016-10-13T02:41:49Z</dc:date>
    <item>
      <title>WHERE Condition Advice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304213#M64738</link>
      <description>&lt;P&gt;Hi. I need to&amp;nbsp;merge these two tables by IMB_CODE and&amp;nbsp;&lt;SPAN&gt;spm_calc_batch_date, but the problem is that&amp;nbsp;spm_calc_batch_date IS NOT always the same on both tables for the same IMB_CODE. This being the case I can't join like this: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WHERE a.imb_code = b.imb_code &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;AND a.spm_calc_batch_date = b.spm_calc_batch_date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I still need to match based on IMB_CODE, but only when they have spm_calc_batch_dates are within 30 days of one another. Is this possible?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to write this type of conditional WHERE condition.&amp;nbsp;Can anyone advise me on how to alter my WHERE statement below to account for this 30 day variance in&amp;nbsp;&lt;SPAN&gt;spm_calc_batch_date variable values? &amp;nbsp;&lt;/SPAN&gt;(Note: IMB_CODE and spm_calc_batch_date on both tables will never be missing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would greatly appreciate any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table QueryData&amp;amp;ZIP5 as
select a.actual_dlvry_date,
     a.imb_code length = 31,
     a.imb_dlvry_zip_5,
     CASE
           WHEN (A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL ) THEN trim("ACTUAL DELIVERY DATE MISSING IN IV ")
           WHEN (A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE ) THEN trim("ACTUAL DELIVERY DATE LATER IN IV ")
     ELSE ' '
     END as RULE_NM,
     CASE
           WHEN (A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL ) THEN 1.0
           WHEN (A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE ) THEN 1.5
     ELSE .
     END as Rule_Order
from mp_bi as a, mp_iv b
where a.imb_code=b.imb_code;
quit;                            &lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 02:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304213#M64738</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-10-13T02:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE Condition Fuzzy Merge Advice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304218#M64740</link>
      <description>&lt;P&gt;I guess then you should only match over codes within a time range of 30 days.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;on a.imb_code=b.imb_code and abs(a.spm_calc_batch_date-b.spm_calc_batch_date)&amp;lt;=30&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2016 02:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304218#M64740</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-13T02:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE Condition Advice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304224#M64744</link>
      <description>Ok, I will try this. Ty.</description>
      <pubDate>Thu, 13 Oct 2016 02:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304224#M64744</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-10-13T02:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE Condition Advice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304226#M64745</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
from 
	mp_bi as a inner join
	mp_iv as b
		on a.imb_code = b.imb_code and
			 a.spm_calc_batch_date between b.spm_calc_batch_date-30 and b.spm_calc_batch_date+30;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Oct 2016 02:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WHERE-Condition-Advice/m-p/304226#M64745</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-13T02:50:22Z</dc:date>
    </item>
  </channel>
</rss>

