<?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 create subset of two dates that occur before a reference date in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248581#M6601</link>
    <description>&lt;P&gt;Thank you for the suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;lilly&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Feb 2016 21:48:18 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2016-02-07T21:48:18Z</dc:date>
    <item>
      <title>how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248468#M6592</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am a researcher who is new to dealing with date in large datasets. I have been trying to code this over last week but the process became complicated. Here is an example of my database:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1776iD6EE9EC7A2EA8481/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="gh.png" title="gh.png" /&gt;&lt;/P&gt;&lt;P&gt;The date_ot is the date the ICD-9 was coded. And date_h= hospital admission date. I am trying to code the following: include people who have two ICD-9 codes of "200" that occur before date of hospitalization "date_h". Any help is apprecaited. Thank you (using SAS 9.4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2016 14:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248468#M6592</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-06T14:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248472#M6593</link>
      <description>Could you please also provide the sample output for better understanding</description>
      <pubDate>Sat, 06 Feb 2016 14:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248472#M6593</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-06T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248482#M6594</link>
      <description>&lt;P&gt;Hi Jag,&lt;/P&gt;&lt;P&gt;Thank you for the reply. I adjusted the above table to make it easy to understand what I am trying to do:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1779i824D288B7A23F27C/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="h1.png" title="h1.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want an output table that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1782i2AA7724DA7EC655F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="gh6.png" title="gh6.png" /&gt;&lt;/P&gt;&lt;P&gt;patient 1 and 3 were excluded because while they had 2 ICD-9 code of "200" they were reported after date_h&lt;/P&gt;&lt;P&gt;patient 2 was excluded because they had 1 ICD-9 code of 200&lt;/P&gt;&lt;P&gt;Only patient 4 was included because the 2 ICD-9 code of 2-- were reported before date_h&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2016 15:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248482#M6594</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-06T15:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248524#M6595</link>
      <description>&lt;P&gt;Thank you for your reply. Please try the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as select id,count(icd_9), icd_9, date_ot,date_h from have where date_ot&amp;lt;date_h
 group by id,icd_9 having count(icd_9)&amp;lt;=2 ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Feb 2016 02:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248524#M6595</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-07T02:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248534#M6596</link>
      <description>&lt;P&gt;In your data could there be more than one hospitalization for a patient? And if yes how should the result look like for such a case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would help is if you could provide sample data as realistic as possible and not as a screen-shot but as data which we can directly process in SAS (eg. a data step creating such data).&lt;/P&gt;
&lt;P&gt;That would help us to provide answers which are tested; and Jag might have realized what's not working in his&amp;nbsp;SQL before posting it as an answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 07:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248534#M6596</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-02-07T07:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248556#M6597</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick﻿&lt;/a&gt;&amp;nbsp;thanks for your response. I would like to correct myself with regard to the code i posted. Could you please help me with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I got the output as expected&amp;nbsp;with the code i posted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the data I used&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id icd_9 date_ot date_h
1 200 7/1/2005 1/1/2005
1 200 2/3/2005 .
1 200 3/3/2004 .
1 201 4/3/2004 .
2 200 5/7/2005 2/1/2005
2 201 5/8/2005 .
3 200 5/9/2005 2/2/2005
3 201 6/4/2004 .
3 200 7/9/2005 .
4 200 5/4/2004 1/1/2005
4 205 5/3/2004 .
4 200 5/2/2004 .&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 14:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248556#M6597</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-07T14:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248557#M6598</link>
      <description>&lt;P&gt;Jag,&lt;/P&gt;&lt;P&gt;Thank you for taking the time to respond. The code works, perfect!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 14:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248557#M6598</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-07T14:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248559#M6599</link>
      <description>&lt;P&gt;&amp;nbsp; I am also trying to find id with 12 months of continous enrollment (no gap) before and after date_h. Each id can have multiple enrollment period (several start_e and end_e dates). In this example only id 1 should be included (have 12 months before and 12 months after).&lt;/P&gt;&lt;P&gt;id 2 will be excluded because there was a gap in coverage between 8/8/2006 and 1/1/2007&lt;/P&gt;&lt;P&gt;id 3 will be excluded because there was 12 months of continous enrollment before but not after date_h.&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;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; start_e end_e     date_h
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; 1&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2005&lt;/SPAN&gt; 1/1/2006  2/8/2008
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; 2&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2006&lt;/SPAN&gt; 4/5/2013
&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2005&lt;/SPAN&gt; 8/8/2006  4/5/2007
&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; 1/1/2007 2/2/2012
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; 5&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;9&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2005&lt;/SPAN&gt; 5/9/2007  1/1/2007
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2008 7/7/2012&lt;/SPAN&gt; 

&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 15:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248559#M6599</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-07T15:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248577#M6600</link>
      <description>&lt;P&gt;Can you please post your question as a new question/thread? Many users won't look at a question that's been marked answered and it helps others later on when searching for similar answers.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 21:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248577#M6600</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-07T21:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248581#M6601</link>
      <description>&lt;P&gt;Thank you for the suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;lilly&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2016 21:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/248581#M6601</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-07T21:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/249866#M6673</link>
      <description>&lt;P&gt;Hi Jag,&lt;/P&gt;&lt;P&gt;the code did not work on the original dataset. You specified count assuming I have the same ICD-9 code but I can have different one&amp;nbsp;not necessarly the one I want.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2016 12:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/249866#M6673</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-02-13T12:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to create subset of two dates that occur before a reference date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/249969#M6694</link>
      <description>hope you tried to change the variable name. could you please let me know the sample data how it actually looks now.</description>
      <pubDate>Sun, 14 Feb 2016 16:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-create-subset-of-two-dates-that-occur-before-a-reference/m-p/249969#M6694</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-02-14T16:31:59Z</dc:date>
    </item>
  </channel>
</rss>

