<?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: Determine if the first occurence of a record was during a given period in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84354#M24172</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's pretty easy if you first sort by name and alert_date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, a simple datastep works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data whatever;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set whatever;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.name and alert_date&amp;gt;'01MAY13'd and alert_date&amp;lt;'05JUL13'd; /* Assumes alert_date is numeric date */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Jul 2013 16:34:52 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2013-07-19T16:34:52Z</dc:date>
    <item>
      <title>Determine if the first occurence of a record was during a given period</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84353#M24171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table like the following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;NAME&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ALERT_DATE&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2010-12-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;nicolas&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-06-20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;nicolas&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-06-30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;bob&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2012-10-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;william&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-07-01&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;guy&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2011-11-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;william&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-07-02&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;julie&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-07-10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;julie&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-07-13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to write a query so that I only keep the records where the first alert for each name was between the 2013-05-01 and 2013-07-05. So I would like to kill all the name that had an alert that was before 2013-05-01 and all the records where the first alert was after 2013-07-05. For each of those name I would like to keep only the first alert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the end result would be :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ALERT_DATE&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;nicolas&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-06-20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;william&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2013-07-01&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me write that query?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 16:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84353#M24171</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-07-19T16:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if the first occurence of a record was during a given period</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84354#M24172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's pretty easy if you first sort by name and alert_date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, a simple datastep works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data whatever;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set whatever;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.name and alert_date&amp;gt;'01MAY13'd and alert_date&amp;lt;'05JUL13'd; /* Assumes alert_date is numeric date */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 16:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84354#M24172</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-07-19T16:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if the first occurence of a record was during a given period</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84355#M24173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works like a charm and makes much sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jul 2013 16:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Determine-if-the-first-occurence-of-a-record-was-during-a-given/m-p/84355#M24173</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-07-19T16:56:08Z</dc:date>
    </item>
  </channel>
</rss>

