<?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 some help with left join tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262793#M51379</link>
    <description>&lt;P&gt;Let's try turning that into words &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Join table1 to table2, summing the column B&amp;nbsp;within 3 and 5 days of the event?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;has the correct answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This confused me, since it's 1997....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43202"&gt;@ygity&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Cumulative news from 31/12/&lt;STRONG&gt;1997&lt;/STRONG&gt; to 03/01/1998&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Apr 2016 03:50:25 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-04-11T03:50:25Z</dc:date>
    <item>
      <title>Left Join and aggregate on date intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262772#M51364</link>
      <description>&lt;P&gt;dear forum...&lt;/P&gt;
&lt;P&gt;i need some help on writeing up the code....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the L.* looks like this&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Code &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01/01/1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the R.* looks like this&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; News&lt;/P&gt;
&lt;P&gt;02/01/1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;03/01/1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;05/01/1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the combined i want looks like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cummulative_news_day0_day5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cummulative_news_day-1_day3&lt;/P&gt;
&lt;P&gt;01/01/1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8(5+2+1)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7(5+2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where day 0 indicates the L.date and day1 day2 means the following dates... and day-1 means the previous day..&lt;/P&gt;
&lt;P&gt;in the example here &lt;STRONG&gt;Cummulative_news_day-1_day3&lt;/STRONG&gt; it got no data from 31/12/1997...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i got stuck at this problem like a week...&lt;/P&gt;
&lt;P&gt;thanks for your time...you the best&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 04:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262772#M51364</guid>
      <dc:creator>ygity</dc:creator>
      <dc:date>2016-04-11T04:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262783#M51370</link>
      <description>&lt;P&gt;How many Cummulative_news_dayxxx columns do you expect?&lt;/P&gt;
&lt;P&gt;You could have millions considering all the combinations of days that are possible..&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 03:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262783#M51370</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-04-11T03:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262787#M51373</link>
      <description>nono... just these two here...&lt;BR /&gt;Cumulative_news_day0_day5&lt;BR /&gt;Cumulative news from 01/01/1998 to 05/01/1998&lt;BR /&gt;Cumulative_news_day-1_day3&lt;BR /&gt;Cumulative news from 31/12/1997 to 03/01/1998&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Apr 2016 03:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262787#M51373</guid>
      <dc:creator>ygity</dc:creator>
      <dc:date>2016-04-11T03:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262789#M51375</link>
      <description>&lt;P&gt;I think you need to explain your problem some more and provide some better sample data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's the logic on the join - by month? Those periods appear to overlap as well?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 03:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262789#M51375</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-11T03:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262791#M51377</link>
      <description>not by month... the L.date is the date of an event happened..&lt;BR /&gt;and surrounding L.date there is the R table observations...&lt;BR /&gt;i want to have the cumulative R.news to be joined with L.*..&lt;BR /&gt;the cumulative day0_day5 means L.date to L.date+5...&lt;BR /&gt;and day-1_day3 means L.date-1 to L.date+3</description>
      <pubDate>Mon, 11 Apr 2016 03:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262791#M51377</guid>
      <dc:creator>ygity</dc:creator>
      <dc:date>2016-04-11T03:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262792#M51378</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data L;
input DATE ddmmyy10. CODE $;   
cards;
01/01/1998          A
run;

data R;
input DATE ddmmyy10. CODE  $ NEWS;   
cards;
02/01/1998          A      5
03/01/1998          A      2
05/01/1998          A      1
run;

proc sql;
  select a.CODE
        ,a.DATE format=date9.
        ,sum( (0&amp;lt;=b.DATE-a.DATE&amp;lt;=5) * NEWS ) as DAY_0_5 
        ,sum( (1&amp;lt;=b.DATE-a.DATE&amp;lt;=3) * NEWS ) as DAY_1_3 
  from L   a
      ,R   b
   where L.CODE=R.CODE
     and (0&amp;lt;=b.DATE-a.DATE&amp;lt;=5)
  group by a.CODE, a.DATE;    
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="table" rules="all" frame="box" cellspacing="0" cellpadding="5" summary="Procedure SQL: Query Results"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;CODE&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;DATE&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;DAY_0_5&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;DAY_1_3&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;A&lt;/TD&gt;
&lt;TD class="r data"&gt;01JAN1998&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 11 Apr 2016 03:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262792#M51378</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-04-11T03:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262793#M51379</link>
      <description>&lt;P&gt;Let's try turning that into words &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Join table1 to table2, summing the column B&amp;nbsp;within 3 and 5 days of the event?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;has the correct answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This confused me, since it's 1997....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43202"&gt;@ygity&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Cumulative news from 31/12/&lt;STRONG&gt;1997&lt;/STRONG&gt; to 03/01/1998&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 03:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262793#M51379</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-11T03:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262795#M51381</link>
      <description>yep because i want from day-1 to day3 of the L.date..</description>
      <pubDate>Mon, 11 Apr 2016 03:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262795#M51381</guid>
      <dc:creator>ygity</dc:creator>
      <dc:date>2016-04-11T03:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262797#M51383</link>
      <description>&lt;P&gt;I modified the subject of the thread to better reflect your problem - helps when searching in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Chris's solution works for you please mark it as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 04:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262797#M51383</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-11T04:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: need some help with left join tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262798#M51384</link>
      <description>thanks so much... i am new to the SAS world.. thanks for the fast and helpful replys</description>
      <pubDate>Mon, 11 Apr 2016 04:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262798#M51384</guid>
      <dc:creator>ygity</dc:creator>
      <dc:date>2016-04-11T04:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join and aggregate on date intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262835#M51397</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data L;
input DATE ddmmyy10. CODE $;   
cards;
01/01/1998          A
run;

data R;
input DATE ddmmyy10. CODE  $ NEWS;   
cards;
02/01/1998          A      5
03/01/1998          A      2
05/01/1998          A      1
run;

proc sql;
 select l.*,
  (select sum(news) 
    from r 
     where r.code=l.code and r.date between l.date and l.date+4 ) 
       as Cummulative_news_day0_day5,
  (select sum(news) 
    from r 
     where r.code=l.code and r.date between l.date+1 and l.date+2 ) 
       as  Cummulative_news_day1_day3
  from l;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2016 08:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Left-Join-and-aggregate-on-date-intervals/m-p/262835#M51397</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-11T08:40:36Z</dc:date>
    </item>
  </channel>
</rss>

