<?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: Is it possible to merge data by a range? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/233842#M5866</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, just use &amp;lt;= with the range:&lt;/P&gt;
&lt;PRE&gt;data testa;
  input nr date_a date_low date_up int $@@;
cards;
1 3 1 5 e
1 5 3 7 ee
2 4 2 6 f
3 8 6 10 g
4 8 6 10 h
4 13 11 15 i
;
run;
data testb;
  input nr date_b empf $@@;
cards;
1 2 a
1 2 b
3 8 c
4 9 d
;
run;
proc sql;
  create table WANT as
  select  A.*,
          B.DATE_B,
          B.EMPF
  from    WORK.TESTA A
  full join WORK.TESTB B
  on      A.NR=B.NR
  and     A.DATE_LOW &amp;lt;= B.DATE_B &amp;lt;= A.DATE_UP;
quit;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Nov 2015 15:08:08 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-11-09T15:08:08Z</dc:date>
    <item>
      <title>Is it possible to merge data by a range?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/233840#M5865</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets (testa and testb)&amp;nbsp;which I like to merge by the date-values . But I can not merge by the date-variable itself because sometimes the dates differ by some days but should be written to the same observation. Therfore I want to introduce a range according to the date of the first dataset und merge the information of the second dataset only if that date fits into that range. On the bottomline I try to solve this problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; testa;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; nr date_a date_low date_up int $@@;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 3 1 5 e&lt;/P&gt;&lt;P&gt;1 5 3 7 ee&lt;/P&gt;&lt;P&gt;2 4 2 6 f&lt;/P&gt;&lt;P&gt;3 8 6 10 g&lt;/P&gt;&lt;P&gt;4 8 6 10 h&lt;/P&gt;&lt;P&gt;4 13 11 15 i&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; testb;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; nr date_b empf $@@;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 2 a&lt;/P&gt;&lt;P&gt;1 2 b&lt;/P&gt;&lt;P&gt;3 8 c&lt;/P&gt;&lt;P&gt;4 9 d&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*This is what I want to get;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; testz;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; nr date_a date_low date_up int $ date_b empf $@@;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 3 1 5 e 2 a&lt;/P&gt;&lt;P&gt;1 3 1 5 e 2 b&lt;/P&gt;&lt;P&gt;1 5 3 7 ee . .&lt;/P&gt;&lt;P&gt;2 4 2 6 f . .&lt;/P&gt;&lt;P&gt;3 8 6 10 g 8 c&lt;/P&gt;&lt;P&gt;4 8 6 10 h 9 d&lt;/P&gt;&lt;P&gt;4 13 11 15 i . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&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, 09 Nov 2015 14:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/233840#M5865</guid>
      <dc:creator>Gundi</dc:creator>
      <dc:date>2015-11-09T14:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to merge data by a range?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/233842#M5866</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, just use &amp;lt;= with the range:&lt;/P&gt;
&lt;PRE&gt;data testa;
  input nr date_a date_low date_up int $@@;
cards;
1 3 1 5 e
1 5 3 7 ee
2 4 2 6 f
3 8 6 10 g
4 8 6 10 h
4 13 11 15 i
;
run;
data testb;
  input nr date_b empf $@@;
cards;
1 2 a
1 2 b
3 8 c
4 9 d
;
run;
proc sql;
  create table WANT as
  select  A.*,
          B.DATE_B,
          B.EMPF
  from    WORK.TESTA A
  full join WORK.TESTB B
  on      A.NR=B.NR
  and     A.DATE_LOW &amp;lt;= B.DATE_B &amp;lt;= A.DATE_UP;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2015 15:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/233842#M5866</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-09T15:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to merge data by a range?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/236737#M6076</link>
      <description>Hi,&lt;BR /&gt;thank you, that helped a lot!&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Nov 2015 15:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/236737#M6076</guid>
      <dc:creator>Gundi</dc:creator>
      <dc:date>2015-11-27T15:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to merge data by a range?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/236966#M6105</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34249" target="_self"&gt;Gundi&lt;/A&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica Neue'; color: #333333;"&gt;I'm glad you found some useful info! If&lt;SPAN class="apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;one of the replies was&amp;nbsp;the exact solution to your problem, can&lt;SPAN class="apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;you&amp;nbsp;"Accept it as a solution"? Or if one was particularly helpful, feel free to "Like" it. This will help other community members&lt;SPAN class="apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;who&amp;nbsp;may run into the same issue know what worked.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica Neue'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica Neue'; color: #333333;"&gt;Thanks!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;FONT size="2"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica Neue'; color: #333333;"&gt;Anna&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 14:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Is-it-possible-to-merge-data-by-a-range/m-p/236966#M6105</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2015-11-30T14:47:22Z</dc:date>
    </item>
  </channel>
</rss>

