<?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: Proc sql: 6 mth look back period from a specific event (SAS 9.4) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-6-mth-look-back-period-from-a-specific-event-SAS-9-4/m-p/549522#M152497</link>
    <description>&lt;P&gt;Posting data in usable form is always a good idea to get more helpful answers than this one &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variables "event_date" and "drug_fill_date" are sas-dates, right?&lt;/P&gt;
&lt;P&gt;You are using the variables "start" and "end" - i can't see them in the table you posted.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Apr 2019 09:03:42 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-04-09T09:03:42Z</dc:date>
    <item>
      <title>Proc sql: 6 mth look back period from a specific event (SAS 9.4)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-6-mth-look-back-period-from-a-specific-event-SAS-9-4/m-p/549498#M152486</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently learning proc sql and I am trying to figure out how to code a 6 month look back period for EVENT. In my data set everyone has had EVENT. I&amp;nbsp; would like to look back 6 months pre EVENT to determine if anyone in my data set filled a prescription for DRUG. I created a flag for whether or not a person has ever filled a prescription (1=yes, 0=no) and I also have the date of drug fill. An example of some of the variables in the the data set is presented in the table below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;How do I create a table with only people who filled the drug in the 6 month look back period?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 180px;" width="448"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;ID&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;EVENT_DATE&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;DRUG 1/0&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;Drug_fill_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;2&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;2/5/00&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;3/12/99&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;2&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;2/5/00&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;4/11/99&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;2&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;2/5/00&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;30/09/99&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;3&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;3/2/04&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;3/1/04&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;3&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;3/2/04&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;3/12/03&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;4&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;4/3/09&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;0&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;5&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;3/5/08&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;1&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;5/9/07&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="height: 20px; width: 90.1167px;"&gt;6&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.783px;"&gt;4/3/11&lt;/TD&gt;
&lt;TD style="height: 20px; width: 90.15px;"&gt;0&lt;/TD&gt;
&lt;TD style="height: 20px; width: 103.95px;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a bare bones version of the code I ran using proc sql&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;data eg1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set eg1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (where=(start = ('event_date'-180)&amp;nbsp; and end ='event_date'));&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table eg2 as&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from eg1&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where start&amp;lt;= Drug_fill_date&amp;lt;= end&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#003300"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me to figure out where I have gone wrong in this code?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 06:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-6-mth-look-back-period-from-a-specific-event-SAS-9-4/m-p/549498#M152486</guid>
      <dc:creator>ajb</dc:creator>
      <dc:date>2019-04-09T06:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql: 6 mth look back period from a specific event (SAS 9.4)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-6-mth-look-back-period-from-a-specific-event-SAS-9-4/m-p/549522#M152497</link>
      <description>&lt;P&gt;Posting data in usable form is always a good idea to get more helpful answers than this one &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variables "event_date" and "drug_fill_date" are sas-dates, right?&lt;/P&gt;
&lt;P&gt;You are using the variables "start" and "end" - i can't see them in the table you posted.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 09:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-6-mth-look-back-period-from-a-specific-event-SAS-9-4/m-p/549522#M152497</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-09T09:03:42Z</dc:date>
    </item>
  </channel>
</rss>

