<?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: Selecting rows in a date range that don't also appear in a secondary date range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501659#M133792</link>
    <description>Thanks so much. I appreciate you taking the time to help. Much appreciated.</description>
    <pubDate>Thu, 04 Oct 2018 18:58:44 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2018-10-04T18:58:44Z</dc:date>
    <item>
      <title>Selecting rows in a date range that don't also appear in a secondary date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501651#M133789</link>
      <description>&lt;P&gt;Hi all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with two variables, MY_ID and MY_DATE.&amp;nbsp; The record MY_DATEs are all between the two year period of '01JUN2016'D AND '31MAY2018'D.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using Proc SQL, I need to pull the IDs that are present with MY_DATEs between&amp;nbsp;'01JUN2017'D AND '31MAY2018'D, but&amp;nbsp;NOT also present between&amp;nbsp;'01JUN2016'D AND '31MAY2017'D.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a suggest for a good way to code this?&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501651#M133789</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-10-04T18:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows in a date range that don't also appear in a secondary date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501655#M133791</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79805"&gt;@buechler66&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with two variables, MY_ID and MY_DATE.&amp;nbsp; The record MY_DATEs are all between the two year period of '01JUN2016'D AND '31MAY2018'D.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Proc SQL, I need to pull the IDs that are present with MY_DATEs between&amp;nbsp;'01JUN2017'D AND '31MAY2018'D, but&amp;nbsp;NOT also present between&amp;nbsp;'01JUN2016'D AND '31MAY2017'D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have a suggest for a good way to code this?&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Should be straight forward to translate your problem statement into SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Using Proc SQL, I need to pull
 the IDs that are present with MY_DATEs between '01JUN2017'D AND '31MAY2018'D
, but NOT also present between '01JUN2016'D AND '31MAY2017'D.
*/
proc sql ;
 select distinct MY_ID from have 
 where MY_DATE between '01JUN2017'D AND '31MAY2018'D

 except 

 select distinct MY_ID from have 
 where MY_DATE between '01JUN2016'D AND '31MAY2017'D
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 18:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501655#M133791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-04T18:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows in a date range that don't also appear in a secondary date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501659#M133792</link>
      <description>Thanks so much. I appreciate you taking the time to help. Much appreciated.</description>
      <pubDate>Thu, 04 Oct 2018 18:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501659#M133792</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2018-10-04T18:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting rows in a date range that don't also appear in a secondary date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501663#M133793</link>
      <description>&lt;P&gt;I would propose:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
 select * from have as a
 where  
    MY_DATE between '01JUN2017'D AND '31MAY2018'D and
    not exists (    select * from have 
                    where   My_ID = a.MY_ID and 
                            MY_DATE between '01JUN2016'D AND '31MAY2017'D )
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-rows-in-a-date-range-that-don-t-also-appear-in-a/m-p/501663#M133793</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-04T19:02:24Z</dc:date>
    </item>
  </channel>
</rss>

