<?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: Need help with merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871020#M344043</link>
    <description>&lt;P&gt;Your question is not clear. Can you also provide the criteria to join the 2 datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be more clear if you can also provide an example over a larger dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Vijay&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 05:41:26 GMT</pubDate>
    <dc:creator>vijaypratap0195</dc:creator>
    <dc:date>2023-04-21T05:41:26Z</dc:date>
    <item>
      <title>Need help with merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/870992#M344041</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data A;
  input ACCT Date mmddyy10.;
  format Date mmddyy10.;
  datalines;
1111 10/31/2022
1111 02/26/2023
;
run;

/* Creating Dataset B */
data B;
  input ACCT Txt $ Src_Date mmddyy10.;
  format Src_Date mmddyy10.;
  datalines;
1111 ABC 03/23/2023
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ACCT&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Txt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1111&lt;/TD&gt;&lt;TD&gt;10/31/2022&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1111&lt;/TD&gt;&lt;TD&gt;02/28/2023&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this result achievable without having a matching date filed? Thanks in advance for any help!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 03:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/870992#M344041</guid>
      <dc:creator>kpdoe</dc:creator>
      <dc:date>2023-04-21T03:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871015#M344042</link>
      <description>&lt;P&gt;Why do you have a date in the example of what you want of 2/28/2023? None of the data you show has that in the source.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably should provide larger example data sets, along with the rule(s) involved in matching. I suspect I can write something that would work for case of exactly two records and exactly one record in the other set that would not extend at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If, as I suspect, the definition is going to involve some sort of "closest" date rule then you need to be very careful in defining how multiple dates that might be the same number of days apart are chosen. Consider a date of 15 Mar 2023 in one set and then other with same ACCT but dates of 13 Mar 2023 and 17 Mar 2023. Both are two days from 15 Mar. So which gets chosen and why.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/146786"&gt;@kpdoe&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data A;
  input ACCT Date mmddyy10.;
  format Date mmddyy10.;
  datalines;
1111 10/31/2022
1111 02/26/2023
;
run;

/* Creating Dataset B */
data B;
  input ACCT Txt $ Src_Date mmddyy10.;
  format Src_Date mmddyy10.;
  datalines;
1111 ABC 03/23/2023
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;ACCT&lt;/TD&gt;
&lt;TD&gt;Date&lt;/TD&gt;
&lt;TD&gt;Txt&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1111&lt;/TD&gt;
&lt;TD&gt;10/31/2022&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1111&lt;/TD&gt;
&lt;TD&gt;02/28/2023&lt;/TD&gt;
&lt;TD&gt;ABC&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this result achievable without having a matching date filed? Thanks in advance for any help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 04:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871015#M344042</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-21T04:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871020#M344043</link>
      <description>&lt;P&gt;Your question is not clear. Can you also provide the criteria to join the 2 datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be more clear if you can also provide an example over a larger dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Vijay&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 05:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871020#M344043</guid>
      <dc:creator>vijaypratap0195</dc:creator>
      <dc:date>2023-04-21T05:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871071#M344081</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
I think you should post more data or example to
illustrate what you are looking for.
*/

data want;
 merge A B(keep=ACCT txt rename=(txt=_txt));
 by ACCT;
 if last.ACCT then txt=_txt;
 drop _txt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2023 11:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-merge/m-p/871071#M344081</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-21T11:50:12Z</dc:date>
    </item>
  </channel>
</rss>

