<?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: Determing prior exposure to a drug within a specified time frame in treatment dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815169#M321746</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408" target="_blank"&gt;Ksharp&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;I think your solution works best for a small dataset, I realise it involves splitting dates into days and this is creating a massive dataset and&amp;nbsp; "memory failure". I have about 50,000 patients with over 20 years of follow-up data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dathan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2022 04:33:52 GMT</pubDate>
    <dc:creator>DathanMD</dc:creator>
    <dc:date>2022-05-26T04:33:52Z</dc:date>
    <item>
      <title>Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/814985#M321701</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I am a junior sas user and I would like your help to crack some code! I have a dataset of antibiotic use by patients &amp;lt;pt_id&amp;gt; over time in a long data format. The antibiotics (&amp;lt;treatment&amp;gt;) have start and end dates (table “have”).&lt;/P&gt;
&lt;P&gt;Table have&lt;/P&gt;
&lt;TABLE width="441"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;pt_id&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;start_date&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;end_date&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;treatment&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;01JAN2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;15MAR2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;16MAR2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;15APRIL2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,midazolam&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;17DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;18DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,penicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;22FEB2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;26FEB2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;01JAN2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;15MAR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;16MAR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;15APR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;17DEC2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;18DEC2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,pethidine&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;22FEB2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;26FEB2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,clopidogrel&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;23JUL2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;29JUL2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,warfarin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;01SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;05SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,tazo&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;06SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;16SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,piperacin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;05DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;18DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;22FEB2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;26FEB2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="45"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="88"&gt;
&lt;P&gt;01JAN2022&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="93"&gt;
&lt;P&gt;15MAR2022&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="215"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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;
&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;I would like to determine if a participant received a specific antibiotic (in this case Flagyl and amoxicillin within six months prior to the start of a given treatment (so the prior end date for that antibiotic falls within six months from the start of a new treatment combination). &amp;nbsp;So, table “want” creates new variables, &amp;lt;expo_flagyl_6m&amp;gt; and &amp;lt;expo_amoxacillin_6m&amp;gt; for prior exposure to flagyl and amoxicillin, respectively, within six months&lt;/P&gt;
&lt;P&gt;Data want&lt;/P&gt;
&lt;TABLE width="604"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;pt_id&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;start_date&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;end_date&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;treatment&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;Expo_flagyl_6m&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;Expo_amoxacillin_6m&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;01JAN2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;15MAR2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;16MAR2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;15APRIL2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,midazolam&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;17DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;18DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,penicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;22FEB2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;26FEB2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;01JAN2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;15MAR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;16MAR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;15APR2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;17DEC2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;18DEC2018&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,pethidine&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;22FEB2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;26FEB2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,clopidogrel&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;23JUL2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;29JUL2020&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,warfarin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;01SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;05SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,tazo&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;06SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;16SEPT2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin,piperacin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;05DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;18DEC2019&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;22FEB2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;26FEB2021&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="37"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="95"&gt;
&lt;P&gt;01JAN2022&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="94"&gt;
&lt;P&gt;15MAR2022&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="217"&gt;
&lt;P&gt;cipro,flagy,amoxicillin&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="76"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="85"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to suggest a macro so that I can run other columns for exposure to other antibiotics?&amp;nbsp; Thank you so much for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dathan Byonanebye&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 04:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/814985#M321701</guid>
      <dc:creator>DathanMD</dc:creator>
      <dc:date>2022-05-25T04:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/814990#M321704</link>
      <description>&lt;P&gt;Please post data in usable form: a data step using datalines.&lt;/P&gt;
&lt;P&gt;Before developing a macro write code without any macro statements, so that you have working code when trying to generalize it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 08:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/814990#M321704</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-05-25T08:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815003#M321707</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input pt_id start_date : date9. end_date : date9.  treatment $80.;
format start_date end_date : date9.;
cards;
1
01JAN2019
15MAR2019
cipro,flagy,amoxicillin
1
16MAR2019
15APR2019
cipro,flagy,amoxicillin,midazolam
1
17DEC2019
18DEC2019
cipro,flagy,amoxicillin,penicillin
1
22FEB2020
26FEB2020
cipro,flagy,
2
01JAN2018
15MAR2018
cipro,amoxicillin
2
16MAR2018
15APR2018
flagy,amoxicillin
2
17DEC2018
18DEC2018
cipro,flagy,amoxicillin,pethidine
2
22FEB2019
26FEB2019
cipro,flagy,amoxicillin,clopidogrel
2
23JUL2020
29JUL2020
cipro,flagy,amoxicillin,warfarin
2
01SEP2021
05SEP2021
cipro,flagy,amoxicillin,tazo
2
06SEP2021
16SEP2021
cipro,flagy,amoxicillin,piperacin
3
05DEC2019
18DEC2019
cipro,flagy,amoxicillin
3
22FEB2021
26FEB2021
cipro,flagy,amoxicillin
3
01JAN2022
15MAR2022
cipro,flagy,amoxicillin
;

data flagy amoxicillin ;
set have;
do i=1 to countw(treatment,',');
 name=scan(treatment,i,',');
 do date=start_date to end_date;
   if name='flagy' then  output flagy;
   if name='amoxicillin' then  output amoxicillin;
 end;
end;
keep date pt_id ;
format date date9.;
run;

data want;
 if _n_=1 then do;
  declare hash h1(dataset:'flagy');
  h1.definekey('pt_id','date');
  h1.definedone();
  declare hash h2(dataset:'amoxicillin');
  h2.definekey('pt_id','date');
  h2.definedone();
 end;
set have;
Expo_flagyl_6m=0;
Expo_amoxacillin_6m=0;
do date=intnx('month',start_date,-6,'s') to start_date-1;
 if h1.check()=0 then Expo_flagyl_6m=1;
 if h2.check()=0 then Expo_amoxacillin_6m=1;
end;
drop date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2022 12:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815003#M321707</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-25T12:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815123#M321735</link>
      <description>&lt;P&gt;You apparently want to set a flag for a given antibiotic if the preceding end_date for that given PT_ID and antibiotic is less than six months prior to the current start_date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given that data is sorted by PT_ID/START_DATE, and there are no overlapping data ranges, you can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:) ;
  set have;
  by pt_id;
  retain _mr_flagy    _mr_amox       ;   /*Most Recent flagy, amoxicillin END_DATES*/

  _cutoff_date=intnx('month',start_date,-6,'s');
  if first.pt_id then call missing(of _mr_:);

  fl_dummy=(first.pt_id=0 and _mr_flagy&amp;gt;=_cutoff_date);
  am_dummy=(first.pt_id=0 and _mr_amox&amp;gt;=_cutoff_date);

  if findw(treatment,'flagy',',') then _mr_flagy=end_date;
  if findw(treatment,'amoxicillin',',') then _mr_amox=end_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited note: If you have several antibiotics to check for, you might want to use arrays for the most-recent dates, the list of antibiotic names, and the set of dummy variables.&amp;nbsp; It will make for a much smaller program, and much less risk of typing errors.&amp;nbsp; Below just uses arrays of size 2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=i _:) ;
  set have;
  by pt_id;

  array _mr_date{2}    _temporary_ ;
  array ablist{2} $11  _temporary_ ('flagy'     ,'amoxicillin'    );
  array ab_dummy{2}                  flagy_dummy  amoxicillin_dummy ;

  _cutoff_date=intnx('month',start_date,-6,'s');
  if first.pt_id then call missing(of _mr_date{*});
 

  do i=1 to 2;
    ab_dummy{i}=(first.pt_id=0 and _mr_date{i}&amp;gt;=_cutoff_date);
    if findw(treatment,trim(ablist{i}),',') then _mr_date{i}=end_date;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just be sure that the dummy variable assignment statement PRECEDES the updating of the most-recent-dates for the corresponding antibiotic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 May 2022 02:59:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815123#M321735</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-28T02:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815168#M321745</link>
      <description>&lt;P&gt;Thanks Mkeintz,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would like to set a flag for a given antibiotic if the preceding end_date(s) for that given PT_ID and antibiotic is less than six months prior to the current start_date. So I am not only scanning the recent preceding entry but also any prior treatments whose end dates fall within the given pt_id and treatment.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It looks like your code looks out for the antibiotic in the most recent treatment (if within six months).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dathan&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 04:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815168#M321745</guid>
      <dc:creator>DathanMD</dc:creator>
      <dc:date>2022-05-26T04:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815169#M321746</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408" target="_blank"&gt;Ksharp&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;I think your solution works best for a small dataset, I realise it involves splitting dates into days and this is creating a massive dataset and&amp;nbsp; "memory failure". I have about 50,000 patients with over 20 years of follow-up data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dathan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 04:33:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815169#M321746</guid>
      <dc:creator>DathanMD</dc:creator>
      <dc:date>2022-05-26T04:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815193#M321760</link>
      <description>You could split the big table into 100 small tables according to patient's ID and running my code 100 times . All these could be done by making a macro .</description>
      <pubDate>Thu, 26 May 2022 11:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815193#M321760</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-05-26T11:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Determing prior exposure to a drug within a specified time frame in treatment dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815300#M321805</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294150"&gt;@DathanMD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It looks like your code looks out for the antibiotic in the most recent treatment (if within six months).&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Not true.&amp;nbsp; Look at the statements:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if findw(treatment,'flagy',',') then _mr_flagy=end_date;
  if findw(treatment,'amoxicillin',',') then _mr_amox=end_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;They update the most recent date only if the incoming record has that particular drug.&amp;nbsp; So, for example,&amp;nbsp; a FLAGY has end_date=31mar2021, and is followed by a two month range (01apr2021-31may2021) without FLAGY, the 31mar2021 will be retained.&amp;nbsp; Given that (1) your data are sorted by PT_ID/START_DATE, and (2) you do not have overlapping date ranges, that means that your will always have available the most recent previous END_DATE for each drug, even if it is not the immediately preceding record.&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;</description>
      <pubDate>Thu, 26 May 2022 19:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Determing-prior-exposure-to-a-drug-within-a-specified-time-frame/m-p/815300#M321805</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-05-26T19:22:06Z</dc:date>
    </item>
  </channel>
</rss>

