<?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: exclude patient who had &amp;gt;=1 claim for drug during the 90 days prior to or on the index date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716634#M221512</link>
    <description>&lt;P&gt;Thank you for your solution!&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2021 20:06:12 GMT</pubDate>
    <dc:creator>lulu3</dc:creator>
    <dc:date>2021-02-03T20:06:12Z</dc:date>
    <item>
      <title>exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716553#M221480</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt;&lt;P&gt;I wanted to exclude patients who have more than one claim of the drug during the 90 dyas prior to or on the index date.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id $ drug $ indexdate mmddyy10.;&lt;BR /&gt;format indexdate mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 A 10/07/2016&lt;BR /&gt;1 B 06/21/2016&lt;BR /&gt;2 C 07/27/2017&lt;BR /&gt;2 A 09/09/2015&lt;BR /&gt;3 A 03/21/2016&lt;BR /&gt;3 B 03/21/2016&lt;BR /&gt;4 C 07/24/2016&lt;BR /&gt;4 B 07/30/2016&lt;BR /&gt;5 A 02/23/2016&lt;BR /&gt;5 C 05/12/2016&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I want:&lt;/P&gt;&lt;P&gt;1 A 10/07/2016&lt;/P&gt;&lt;P&gt;1 B 06/21/2016&lt;/P&gt;&lt;P&gt;2 C 07/27/2017&lt;/P&gt;&lt;P&gt;2 A 09/09/2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to exclude id 3 4 5 because they had two drug claims within 90 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716553#M221480</guid>
      <dc:creator>lulu3</dc:creator>
      <dc:date>2021-02-03T17:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716560#M221482</link>
      <description>&lt;P&gt;You don't show any dates other than Indexdate, so I am not sure what you expect to compare with the values of indexdate. OR you need to define how we can tell that a specific date in the example is supposed to be considered an "index date".&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 17:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716560#M221482</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-03T17:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716565#M221484</link>
      <description>&lt;P&gt;Yes, I wanted to compare with the values of indexdate for each subject.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 18:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716565#M221484</guid>
      <dc:creator>lulu3</dc:creator>
      <dc:date>2021-02-03T18:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716584#M221487</link>
      <description>&lt;P&gt;I repeat: HOW do we know which date is the "index date".&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 18:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716584#M221487</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-03T18:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716587#M221489</link>
      <description>Sorry for the confusion. Please use the earliest drug date as the indexdate for each subject.</description>
      <pubDate>Wed, 03 Feb 2021 18:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716587#M221489</guid>
      <dc:creator>lulu3</dc:creator>
      <dc:date>2021-02-03T18:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716617#M221502</link>
      <description>&lt;P&gt;You need to read each id twice:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The first time determines the earliest and 2nd earliest dates.&lt;/LI&gt;
&lt;LI&gt;The second pass output record for any id with 2nd earliest more than 90 days after the earliest&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Each mention of HAVE in the SET statement represents one pass of the records for a given ID:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ drug $ indexdate mmddyy10.;
format indexdate mmddyy10.;
datalines;
1 A 10/07/2016
1 B 06/21/2016
2 C 07/27/2017
2 A 09/09/2015
3 A 03/21/2016
3 B 03/21/2016
4 C 07/24/2016
4 B 07/30/2016
5 A 02/23/2016
5 C 05/12/2016
;
run;

data want (drop=_:);
  retain _mindate1 _mindate2;
  set have (in=firstpass) have (in=secondpass);
  by id;

  if first.id then call missing(of _mindate:);

  if firstpass=1 then do;
    if indexdate=min(indexdate,_mindate1) then do;
      _mindate2=_mindate1;
      _mindate1=indexdate;
    end;
    else _mindate2=min(_mindate2,indexdate);
  end;

  if secondpass=1 and _mindate2-_mindate1&amp;gt;90;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And THANK YOU for posting you data set in almost perfect format.&amp;nbsp; ("Perfect" would have been if you inserted it in a SAS Code popup (use the "running man" icon, but your code was directly copyable and usable.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 19:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716617#M221502</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-02-03T19:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: exclude patient who had &gt;=1 claim for drug during the 90 days prior to or on the index date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716634#M221512</link>
      <description>&lt;P&gt;Thank you for your solution!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 20:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exclude-patient-who-had-gt-1-claim-for-drug-during-the-90-days/m-p/716634#M221512</guid>
      <dc:creator>lulu3</dc:creator>
      <dc:date>2021-02-03T20:06:12Z</dc:date>
    </item>
  </channel>
</rss>

