<?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: How to compare date range for same id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589902#M168785</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/195588"&gt;@amber7391&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Read each BY group twice:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;On the first read, skip the Y-records and determine the boundaries for the Y-conditions based on the X-values.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;On the second read, skip the X-records and filter the Y-records based on the conditions discovered in #1.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                              
  input id (visit_date check_in check_out) (:mmddyy8.) type :$1. ;       
  format v: c: yymmdd10. ;                                               
  cards ;                                                                
1  1/29/19  1/23/19   1/29/19  x                                         
1  1/26/19  .         .        y                                         
2  2/01/19  .         .        y                                         
2  2/02/19  2/02/19   2/06/19  x                                         
3  3/03/19  3/05/19   3/20/19  x                                         
3  3/05/19  3/05/19   3/20/19  y                                         
4  4/23/19  4/24/19   4/27/19  x                                         
4  4/24/19  4/24/19   4/27/19  y                                         
4  8/08/19  .         .        y                                         
5  9/01/19  .         .        y                                         
5  9/04/19  9/04/19   9/06/19  x                                         
5 10/10/19 10/10/19  10/21/19  y                                         
;                                                                        
run ;                                                                    
                                                                         
data want (drop = _:) ;                                                  
  _xi_min = constant ("big") ;                                           
  _xv_min = constant ("big") ;                                           
  do _n_ = 1 by 1 until (last.id) ;                                      
    set have ;                                                           
    by id ;                                                              
    if type = "y" then continue ;                                        
    _xi_min = _xi_min min check_in ;                                     
    _xo_max = _xo_max max check_out ;                                    
    _xv_min = _xv_min min visit_date ;                                   
    _xv_max = _xv_max max visit_date ;                                   
  end ;                                                                  
  do _n_ = 1 to _n_ ;                                                    
    set have ;                                                           
    if type = "x" then continue ;                                        
    if _xi_min &amp;lt;= visit_date &amp;lt;= _xo_max then continue ;                  
    if visit_date &amp;lt;= _xv_min &amp;lt;= _xv_max &amp;lt;= visit_date + 3 then continue ;
    output ;                                                             
  end ;                                                                  
run ;                                                                    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 04:05:41 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-09-19T04:05:41Z</dc:date>
    <item>
      <title>How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589829#M168753</link>
      <description>&lt;P&gt;Hey guys, I am new to SAS.&lt;/P&gt;&lt;P&gt;I have a problem which looks like the following.&lt;/P&gt;&lt;P&gt;There are two types of visits, x and&amp;nbsp;y.&lt;/P&gt;&lt;P&gt;The data has already sorted based on id and visit date.&lt;/P&gt;&lt;P&gt;Now I want to exclude all the x type visits for each id number.&lt;/P&gt;&lt;P&gt;Also, if the&amp;nbsp;visit date&amp;nbsp;of y type falls in the range of x's check in and check out date, it also needs to be excluded.&lt;/P&gt;&lt;P&gt;Moreover, if there is an x type visit in 3 days after y type visit, both of them need to be excluded.&lt;/P&gt;&lt;P&gt;Can someone please help???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how the raw data look like:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;visit date&lt;/TD&gt;&lt;TD&gt;check in&amp;nb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TD&gt;&lt;TD&gt;type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;8/8/19&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10/10/19&lt;/TD&gt;&lt;TD&gt;10/10/19&lt;/TD&gt;&lt;TD&gt;10/21/19&lt;/TD&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 02:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589829#M168753</guid>
      <dc:creator>amber7391</dc:creator>
      <dc:date>2019-09-19T02:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589847#M168761</link>
      <description>&lt;P&gt;First thing is start with a SAS data set with date values. From you post it looks like you are copying from Excel and so we can't be sure what some of those dates might actually be: 23-Jan for example. Or whether you may have a mix of character and actual date values in Excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to show what you expect your output to actually look like when you are done.&lt;/P&gt;
&lt;P&gt;Since you have moderately complex rules involving intervals and order this is likely not going to get a simple to understand single step solution.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 21:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589847#M168761</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-18T21:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589888#M168778</link>
      <description>Hi ballardw, thanks for pointing that out. I have corrected the format and added the result I would like to have. If you dont mind you can take a look. I really appreciate it!</description>
      <pubDate>Thu, 19 Sep 2019 02:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589888#M168778</guid>
      <dc:creator>amber7391</dc:creator>
      <dc:date>2019-09-19T02:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589894#M168783</link>
      <description>&lt;P&gt;Why is ID 2 dropped?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 02:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589894#M168783</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-19T02:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589902#M168785</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/195588"&gt;@amber7391&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Read each BY group twice:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;On the first read, skip the Y-records and determine the boundaries for the Y-conditions based on the X-values.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;On the second read, skip the X-records and filter the Y-records based on the conditions discovered in #1.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                              
  input id (visit_date check_in check_out) (:mmddyy8.) type :$1. ;       
  format v: c: yymmdd10. ;                                               
  cards ;                                                                
1  1/29/19  1/23/19   1/29/19  x                                         
1  1/26/19  .         .        y                                         
2  2/01/19  .         .        y                                         
2  2/02/19  2/02/19   2/06/19  x                                         
3  3/03/19  3/05/19   3/20/19  x                                         
3  3/05/19  3/05/19   3/20/19  y                                         
4  4/23/19  4/24/19   4/27/19  x                                         
4  4/24/19  4/24/19   4/27/19  y                                         
4  8/08/19  .         .        y                                         
5  9/01/19  .         .        y                                         
5  9/04/19  9/04/19   9/06/19  x                                         
5 10/10/19 10/10/19  10/21/19  y                                         
;                                                                        
run ;                                                                    
                                                                         
data want (drop = _:) ;                                                  
  _xi_min = constant ("big") ;                                           
  _xv_min = constant ("big") ;                                           
  do _n_ = 1 by 1 until (last.id) ;                                      
    set have ;                                                           
    by id ;                                                              
    if type = "y" then continue ;                                        
    _xi_min = _xi_min min check_in ;                                     
    _xo_max = _xo_max max check_out ;                                    
    _xv_min = _xv_min min visit_date ;                                   
    _xv_max = _xv_max max visit_date ;                                   
  end ;                                                                  
  do _n_ = 1 to _n_ ;                                                    
    set have ;                                                           
    if type = "x" then continue ;                                        
    if _xi_min &amp;lt;= visit_date &amp;lt;= _xo_max then continue ;                  
    if visit_date &amp;lt;= _xv_min &amp;lt;= _xv_max &amp;lt;= visit_date + 3 then continue ;
    output ;                                                             
  end ;                                                                  
run ;                                                                    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 04:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589902#M168785</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-19T04:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589904#M168787</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;The X-record is killed unconditionally.&lt;/P&gt;
&lt;P&gt;The Y-record is killed since the visit date of the X-record (2/02/19) is within 3 days after the visit date of the Y-record (2/01/19).&lt;/P&gt;
&lt;P&gt;Hence, the whole ID=2 group is a goner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 04:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589904#M168787</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-19T04:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589906#M168789</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;Ha! Of course! The reversed American dates got me again!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 04:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589906#M168789</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-19T04:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589909#M168790</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Ha's on me: After almost 30 revolutions round the Sun, I still have to make a concerted effort to remind myself of that (the European dd/mm/yy is better but still makes just as much sense as writing the number 753 as 357). That's why I abhor when sample data dates are presented as mm/dd/yy or dd-Mon-yy (they make no sense when sorted) and always both present them and format them as yymmdd10. Hierarchical numbers must come higher order to lower order, left to right; only then they're comprehended properly when ordered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 04:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589909#M168790</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-19T04:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589914#M168793</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&amp;nbsp;Totally with you on compulsory use of yymmdd under the penalty of imprisonment with hard labour! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 05:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589914#M168793</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-19T05:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589918#M168795</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Those using mmddyy and such bring hard labor on themselves, getting self-imprisoned by having to sift through unsorted mess.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 05:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589918#M168795</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-19T05:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589953#M168806</link>
      <description>&lt;P&gt;These kind of problems are most easily solved in SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as select * from have y
    where type='y' 
      and not exists(select * from have x 
                      where type='x' 
			and x.id=y.id
			and (y.visit_date between x.check_in and x.check_out
			     or y.visit_date between x.visit_date-3 and x.visit_date));
quit;       &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 08:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/589953#M168806</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-09-19T08:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590006#M168821</link>
      <description>&lt;PRE&gt;

data have ;                                                              
  input id (visit check_in check_out) (:mmddyy8.) type :$1. ;       
  format v: c: yymmdd10. ;                                               
  cards ;                                                                
1  1/29/19  1/23/19   1/29/19  x                                         
1  1/26/19  .         .        y                                         
2  2/01/19  .         .        y                                         
2  2/02/19  2/02/19   2/06/19  x                                         
3  3/03/19  3/05/19   3/20/19  x                                         
3  3/05/19  3/05/19   3/20/19  y                                         
4  4/23/19  4/24/19   4/27/19  x                                         
4  4/24/19  4/24/19   4/27/19  y                                         
4  8/08/19  .         .        y                                         
5  9/01/19  .         .        y                                         
5  9/04/19  9/04/19   9/06/19  x                                         
5 10/10/19 10/10/19  10/21/19  y                                         
;                                                                        
run ;

proc sql;
create table want as
 select distinct a.*
  from (select * from have where type='y') as a ,
       (select * from have where type='x') as b
where a.id=b.id and a.visit not between b.check_in and b.check_out
and b.visit not between a.visit and a.visit+3;
quit; 


&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 13:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590006#M168821</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-19T13:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590372#M168958</link>
      <description>Thank you soooo much for help me out hashman! I really appreciate it. It fixed my problem perfectly!</description>
      <pubDate>Fri, 20 Sep 2019 13:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590372#M168958</guid>
      <dc:creator>amber7391</dc:creator>
      <dc:date>2019-09-20T13:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590373#M168959</link>
      <description>s_lassen thank you so much!</description>
      <pubDate>Fri, 20 Sep 2019 13:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590373#M168959</guid>
      <dc:creator>amber7391</dc:creator>
      <dc:date>2019-09-20T13:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare date range for same id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590374#M168960</link>
      <description>Ksharp thank you so much!</description>
      <pubDate>Fri, 20 Sep 2019 13:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-date-range-for-same-id/m-p/590374#M168960</guid>
      <dc:creator>amber7391</dc:creator>
      <dc:date>2019-09-20T13:16:38Z</dc:date>
    </item>
  </channel>
</rss>

