<?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: Counting days between dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123311#M293914</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using a DO UNTIL allows for a compact solution to this problem. I didn't sort by APP, as it could disrupt the DATE order within a GROUP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INPUT GROUP APP DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; FORMAT DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATALINES;&lt;BR /&gt;1 100 04/19/2010&lt;BR /&gt;1 101 07/26/2010&lt;BR /&gt;1 102 11/08/2010&lt;BR /&gt;1 103 11/20/2010&lt;BR /&gt;1 104 12/10/2010&lt;BR /&gt;2 105 12/06/2012&lt;BR /&gt;2 106 12/10/2012&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by GROUP DATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do until (last.GROUP);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set lags; by GROUP;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(previousDATE) or intck("DAY", previousDATE, DATE) &amp;gt; 30 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previousDATE = DATE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;drop previousDATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Feb 2013 01:16:44 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-02-28T01:16:44Z</dc:date>
    <item>
      <title>Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123307#M293910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to grab records from a data set that fit a particular criteria. The Output shown below contains the dates in which I am trying to compare to see if they are within a certain time frame from one another. What I am trying to do is to only output the records in which the date is &amp;gt; 30 days from previously output record (for each group). So in the case below, the final data set would only contain APP's 100,101,102,104,105. Also, the first record per group should always be in the final data set, and there could be 25 records in between 2 final dates so a simple lag or lag2 is out of the picture.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;DATA lags ; &lt;/P&gt;&lt;P&gt;&amp;nbsp; INPUT GROUP APP DATE MMDDYY10. ; &lt;/P&gt;&lt;P&gt;&amp;nbsp; FORMAT DATE MMDDYY10.;&lt;/P&gt;&lt;P&gt;DATALINES ; &lt;/P&gt;&lt;P&gt;1 100 04/19/2010&lt;/P&gt;&lt;P&gt;1 101 07/26/2010&lt;/P&gt;&lt;P&gt;1 102 11/08/2010&lt;/P&gt;&lt;P&gt;1 103 11/20/2010&lt;/P&gt;&lt;P&gt;1 104 12/10/2010&lt;/P&gt;&lt;P&gt;2 105 12/06/2012&lt;/P&gt;&lt;P&gt;2 106 12/10/2012&lt;/P&gt;&lt;P&gt;; &lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" style="width: 202px; border-width: 0px; border-color: #000000; border-style: solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;" width="64"&gt;GROUP&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;" width="63"&gt;APP&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;" width="75"&gt;DATE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;100&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;04/19/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;101&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;07/26/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;102&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;11/08/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;103&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;11/20/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;104&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;12/10/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;105&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;12/06/2012&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;106&lt;/TD&gt;&lt;TD class="xl64" style="color: #575757; text-align: center; padding: 0px; background-color: transparent; font-family: arial,helvetica,sans-serif;"&gt;12/10/2012&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 20:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123307#M293910</guid>
      <dc:creator>triley</dc:creator>
      <dc:date>2013-02-27T20:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123308#M293911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Those look identical to me, is that sample data or sample output? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123308#M293911</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-27T21:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123309#M293912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry for not being clear....&lt;/P&gt;&lt;P&gt;The output I am trying to get should look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;NaN&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;transparent&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;" width="64"&gt;GROUP&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;" width="63"&gt;APP&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;" width="75"&gt;DATE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;100&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;04/19/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;101&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;07/26/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;102&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;11/08/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;1&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;104&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;12/10/2010&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;2&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;105&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-style: solid; border-color: #000000; border-width: 0px; font-family: arial,helvetica,sans-serif; text-align: center; color: #575757;"&gt;12/06/2012&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 21:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123309#M293912</guid>
      <dc:creator>triley</dc:creator>
      <dc:date>2013-02-27T21:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123310#M293913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How does this look?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INPUT GROUP APP DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; FORMAT DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATALINES;&lt;BR /&gt;1 100 04/19/2010&lt;BR /&gt;1 101 07/26/2010&lt;BR /&gt;1 102 11/08/2010&lt;BR /&gt;1 103 11/20/2010&lt;BR /&gt;1 104 12/10/2010&lt;BR /&gt;2 105 12/06/2012&lt;BR /&gt;2 106 12/10/2012&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;proc sort data = lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; by GROUP APP DATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data lags_retain;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set lags;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by GROUP APP DATE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; retain tmp_DATE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if first.GROUP then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp_DATE = DATE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if DATE - tmp_DATE &amp;gt; 30 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&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; tmp_DATE = DATE;&lt;BR /&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; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data lags_retain_out;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set lags_retain (drop =&amp;nbsp; tmp_:);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matches your output, but you probably haven't put in all the cases you wanted to cover in your sample, so it's hard to check.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 22:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123310#M293913</guid>
      <dc:creator>JohnT</dc:creator>
      <dc:date>2013-02-27T22:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123311#M293914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using a DO UNTIL allows for a compact solution to this problem. I didn't sort by APP, as it could disrupt the DATE order within a GROUP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INPUT GROUP APP DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; FORMAT DATE MMDDYY10.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATALINES;&lt;BR /&gt;1 100 04/19/2010&lt;BR /&gt;1 101 07/26/2010&lt;BR /&gt;1 102 11/08/2010&lt;BR /&gt;1 103 11/20/2010&lt;BR /&gt;1 104 12/10/2010&lt;BR /&gt;2 105 12/06/2012&lt;BR /&gt;2 106 12/10/2012&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data = lags;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by GROUP DATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do until (last.GROUP);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set lags; by GROUP;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(previousDATE) or intck("DAY", previousDATE, DATE) &amp;gt; 30 then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previousDATE = DATE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;drop previousDATE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 01:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123311#M293914</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-02-28T01:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123312#M293915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should retain the previously output date into another variable. Then you can compare the current records DATE value to see if it is more than 30 days after the previously output date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set lags;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; by group ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; retain prevdate 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format prevdate yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if first.group or (date - prevdate &amp;gt; 30) then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevdate=date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 02:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123312#M293915</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-28T02:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123313#M293916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All the solutions were helpful and i appreciate the input!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2013 14:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-days-between-dates/m-p/123313#M293916</guid>
      <dc:creator>triley</dc:creator>
      <dc:date>2013-02-28T14:01:48Z</dc:date>
    </item>
  </channel>
</rss>

