<?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: Big Merge Troubles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269489#M53401</link>
    <description>&lt;P&gt;Hi mate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This might make sense:&amp;nbsp;&lt;A title="Joining two datasets with the closest observation in terms of time stamp" href="https://communities.sas.com/t5/SAS-Procedures/Joining-two-datasets-with-the-closest-observation-in-terms-of/td-p/150116" target="_blank"&gt;Joining two datasets with the closest observation in terms of time stamp&lt;/A&gt;&amp;nbsp;or&lt;/P&gt;
&lt;P&gt;&lt;A title="Combine datasets based on inexact time" href="https://communities.sas.com/t5/General-SAS-Programming/Combine-datasets-based-on-inexact-time/td-p/112223" target="_blank"&gt;Combine datasets based on inexact time&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="A One-Step Method for Finding the Closest Match " href="http://www.lexjansen.com/pharmasug/2003/CodersCorner/cc001.pdf" target="_blank"&gt;A One-Step Method for Finding the Closest Match &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="Possible to merge by dates within a range?" href="https://communities.sas.com/t5/Base-SAS-Programming/Possible-to-merge-by-dates-within-a-range/td-p/75275" target="_blank"&gt;Possible to merge by dates within a range?&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 May 2016 15:50:14 GMT</pubDate>
    <dc:creator>DartRodrigo</dc:creator>
    <dc:date>2016-05-10T15:50:14Z</dc:date>
    <item>
      <title>Big Merge Troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269487#M53400</link>
      <description>&lt;P&gt;Hi. Until today I had been told both imb_code and spm_calc_batch_date would be match between both my datasets, so the below Merge made sense. &amp;nbsp;However now the requirement has been changed and I'm honestly stumped. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imb_code will match imb_code, but now the IV dataset's version of spm_calc_batch_date &amp;nbsp;can differ to within 45 days of the BIDS's dataset version spm_calc_batch_date. This is because imb_codes get recycled after 45 days and my dataset contains over 90 days of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the bottom line is I need to merge by imb_code and spm_calc_batch_date (within a 45 day window). &amp;nbsp;Is this even possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* BIDS Version ;&lt;BR /&gt;proc sort data=bids_ora.bi_spm_piece_recon out=BIDS_bi_spm_piece_recon;
  by imb_code spm_calc_batch_date;
run;
&lt;BR /&gt;*IV Version ;
proc sort data=iv_ora.bi_spm_piece_recon out=IV_bi_spm_piece_recon;
  by imb_code spm_calc_batch_date;
run;

* RULE: PIECES MISSING IN IV QUERY ;
data QueryData;
  merge BIDS_bi_spm_piece_recon (in=a)
                  IV_bi_spm_piece_recon (in=b);
  by imb_code spm_calc_batch_date;
  if a and not b;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 15:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269487#M53400</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-10T15:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: Big Merge Troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269489#M53401</link>
      <description>&lt;P&gt;Hi mate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This might make sense:&amp;nbsp;&lt;A title="Joining two datasets with the closest observation in terms of time stamp" href="https://communities.sas.com/t5/SAS-Procedures/Joining-two-datasets-with-the-closest-observation-in-terms-of/td-p/150116" target="_blank"&gt;Joining two datasets with the closest observation in terms of time stamp&lt;/A&gt;&amp;nbsp;or&lt;/P&gt;
&lt;P&gt;&lt;A title="Combine datasets based on inexact time" href="https://communities.sas.com/t5/General-SAS-Programming/Combine-datasets-based-on-inexact-time/td-p/112223" target="_blank"&gt;Combine datasets based on inexact time&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="A One-Step Method for Finding the Closest Match " href="http://www.lexjansen.com/pharmasug/2003/CodersCorner/cc001.pdf" target="_blank"&gt;A One-Step Method for Finding the Closest Match &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="Possible to merge by dates within a range?" href="https://communities.sas.com/t5/Base-SAS-Programming/Possible-to-merge-by-dates-within-a-range/td-p/75275" target="_blank"&gt;Possible to merge by dates within a range?&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 15:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269489#M53401</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2016-05-10T15:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Big Merge Troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269494#M53404</link>
      <description>&lt;P&gt;SQL is really good at this type of merge. You can play with the join condition with calculations.&lt;/P&gt;
&lt;P&gt;I'm not sure how the a not b would end up resolving in a situation like this. If the record is in A, not B there wouldn't be dates to join on to check the date interval?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a start. Mock up some test data and play around until you get what you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL Join types are documented here:&amp;nbsp;&lt;A href="http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins" target="_blank"&gt;http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins&lt;/A&gt;&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 as
select *
from BIDS_bi_spm_piece_recon as a
left join IV_bi_spm_piece_recon as b
on a.imb_code=b.imb_code
and a.spm_calc_batch_date - b.spm_calc_batch_date between 0 and 45;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 May 2016 15:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269494#M53404</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-10T15:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Big Merge Troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269504#M53411</link>
      <description>&lt;P&gt;I agree with Reeza.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 16:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269504#M53411</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2016-05-10T16:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Big Merge Troubles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269506#M53412</link>
      <description>&lt;P&gt;Yes, by using between - and join criteria in SQL, given I understood the matching criteria correctly.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Big-Merge-Troubles/m-p/269506#M53412</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-05-10T16:20:16Z</dc:date>
    </item>
  </channel>
</rss>

