<?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 two non-matching data sets in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/393102#M66321</link>
    <description>&lt;P&gt;That's exactly what I'm trying to do, to no avail so far &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2017 06:44:38 GMT</pubDate>
    <dc:creator>totuomin1</dc:creator>
    <dc:date>2017-09-05T06:44:38Z</dc:date>
    <item>
      <title>Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392935#M66302</link>
      <description>&lt;P&gt;Hi, I'm trying to merge two sets by date, but haven't found a solution yet. The dates are from two different years, which is probably the cause of the merging problem. I used DATEPART to extract the date5. format, but it seems the year part is still in there somewhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set 1&lt;/P&gt;&lt;P&gt;date &amp;nbsp;value&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set 2&lt;/P&gt;&lt;P&gt;date value&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;e&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; f&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; g&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;h&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date value1 value2&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;e&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;g&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; d &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;h&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to solve this issue? Sorry if this is a stupid question, still a SAS newbie.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 08:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392935#M66302</guid>
      <dc:creator>totuomin1</dc:creator>
      <dc:date>2017-09-04T08:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392942#M66303</link>
      <description>&lt;P&gt;Regarding the date problem you need to supply more information, 'bout the merge, try the merge &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; value $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date value;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 a&lt;/P&gt;
&lt;P&gt;2 b&lt;/P&gt;
&lt;P&gt;4 c&lt;/P&gt;
&lt;P&gt;6 d&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; value $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date value;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 e&lt;/P&gt;
&lt;P&gt;3 f&lt;/P&gt;
&lt;P&gt;5 g&lt;/P&gt;
&lt;P&gt;6 h&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; tog;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;merge&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;rename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=(value=value1)) two(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;rename&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=(value=value2));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 08:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392942#M66303</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2017-09-04T08:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392946#M66304</link>
      <description>&lt;P&gt;Please post your test data in the form of a datastep, and use data which acurately reflects the data you are using. &amp;nbsp;I can tell nothing about structure from what you have posted, nor is the date column reflective of a date. &amp;nbsp;You can use this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get datasets of your exact data. &amp;nbsp;Once we can see what is actually there, then we can advise futher. &amp;nbsp;Do note that formatting a numeric date does&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; change the underlying number, just how it is represented, so bear that in mind, datepart function returns the date - all of the date including year month and day - from a datetime variable. &amp;nbsp;Valid numeric dates have to have all the parts. &amp;nbsp;If you just want to merge on month and day( and why as that makes no sense) then you need to put the value to a character and use that.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 08:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392946#M66304</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-04T08:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392947#M66305</link>
      <description>&lt;P&gt;I used DATEPART combined with date5., and the data is from 2016 and 2017, Jan 01 - Aug 31 in both cases.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I MERGE the two tables BY DATE, I receive&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 a&lt;/P&gt;&lt;P&gt;2 b&lt;/P&gt;&lt;P&gt;4 c&lt;/P&gt;&lt;P&gt;6 d&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; e&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; f&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; g&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; h&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, the year part seems to have remained in date despite using the date5. format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your example works perfectly, if only I knew how to apply it to my data properly.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 08:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392947#M66305</guid>
      <dc:creator>totuomin1</dc:creator>
      <dc:date>2017-09-04T08:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392967#M66306</link>
      <description>&lt;P&gt;It sounds like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Your original date variables are actually date-time values, hence the need to apply DATEPART, and&lt;/LI&gt;
&lt;LI&gt;One data set contains data for 2016, while the other contains data for 2017. &amp;nbsp;You would like to match based on the day of the year.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Does that sound about right?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 10:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/392967#M66306</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-04T10:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/393102#M66321</link>
      <description>&lt;P&gt;That's exactly what I'm trying to do, to no avail so far &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 06:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/393102#M66321</guid>
      <dc:creator>totuomin1</dc:creator>
      <dc:date>2017-09-05T06:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two non-matching data sets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/393110#M66322</link>
      <description>&lt;P&gt;This goes to show why providing test data in the form of a datastep and what that test data should ouput is so important, we are still guessing what the data looks like and what you want out. &amp;nbsp;So I have give an example here with test data I made up and to an output I think you want:&lt;/P&gt;
&lt;PRE&gt;data have1;
  date="01JAN2016T12:12:00"dt; value="a"; output;
  date="10FEB2016T02:20:00"dt; value="b"; output;
run;
data have2;
  date="01JAN2017T12:12:00"dt; value="e"; output;
  date="11FEB2017T02:20:00"dt; value="f"; output;
run;
proc sql;
  create table WANT as
  select  coalesce(substr(put(A.DATE,datetime.),1,5),substr(put(B.DATE,datetime.),1,5)) as DATE,
          A.VALUE as VALUE1,
          B.VALUE as VALUE2
  from    HAVE1 A
  full join HAVE2 B
  on      substr(put(A.DATE,datetime.),1,5)=substr(put(B.DATE,datetime.),1,5);
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 08:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-two-non-matching-data-sets/m-p/393110#M66322</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-05T08:01:25Z</dc:date>
    </item>
  </channel>
</rss>

