<?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: Date range question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59541#M16793</link>
    <description>I read the entire line in as a character string, and used list input to get each part separately so I had the dates.&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input @1  x                  $40.&lt;BR /&gt;
        @1 range              $7.&lt;BR /&gt;
              date1   mmddyy8.&lt;BR /&gt;
              hyphen            $1.&lt;BR /&gt;
              date2   mmddyy8.&lt;BR /&gt;
              obser                2.;&lt;BR /&gt;
cards;&lt;BR /&gt;
range1  8/25/09 - 9/22/09 8&lt;BR /&gt;
range2  9/26/09 - 10/21/09 10&lt;BR /&gt;
range6  12/29/09 - 1-19/10 5&lt;BR /&gt;
range7  1/20/10 - 2/20/10 6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp;&lt;BR /&gt;
  set temp;&lt;BR /&gt;
y = lag(x);&lt;BR /&gt;
if date1 LE today() LE date2 then output;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
var y;&lt;BR /&gt;
run;&lt;BR /&gt;
Message was edited by: garybald&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: garybald&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: garybald

Message was edited by: garybald</description>
    <pubDate>Thu, 18 Feb 2010 20:27:36 GMT</pubDate>
    <dc:creator>garybald</dc:creator>
    <dc:date>2010-02-18T20:27:36Z</dc:date>
    <item>
      <title>Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59540#M16792</link>
      <description>Hello All,&lt;BR /&gt;
       I am having a little trouble in figuring this out, may be you can provide some insight.&lt;BR /&gt;
I have a dataset which has range of dates grouped as ranges.&lt;BR /&gt;
&lt;BR /&gt;
eg. range1 8/25/09 - 9/22/09(all dates inclusive)   8&lt;BR /&gt;
range2 9/26/09 - 10/21/09        10&lt;BR /&gt;
-&lt;BR /&gt;
range 6  12/29/09 - 1/19/10    5&lt;BR /&gt;
range 7  1/20/10 - 2/20/10        6&lt;BR /&gt;
&lt;BR /&gt;
and so on&lt;BR /&gt;
my problem is I have to find in which range does today's fall under (in this example range 7). Once I find the range, I need the data for the previous range (in my example range6) Each range has a no. of obsevations associated with it as shown above. I want my output to be &lt;BR /&gt;
&lt;BR /&gt;
range 6  12/29/09 - 1/19/10     5&lt;BR /&gt;
&lt;BR /&gt;
Any help is greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Shri</description>
      <pubDate>Thu, 18 Feb 2010 16:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59540#M16792</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-18T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59541#M16793</link>
      <description>I read the entire line in as a character string, and used list input to get each part separately so I had the dates.&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input @1  x                  $40.&lt;BR /&gt;
        @1 range              $7.&lt;BR /&gt;
              date1   mmddyy8.&lt;BR /&gt;
              hyphen            $1.&lt;BR /&gt;
              date2   mmddyy8.&lt;BR /&gt;
              obser                2.;&lt;BR /&gt;
cards;&lt;BR /&gt;
range1  8/25/09 - 9/22/09 8&lt;BR /&gt;
range2  9/26/09 - 10/21/09 10&lt;BR /&gt;
range6  12/29/09 - 1-19/10 5&lt;BR /&gt;
range7  1/20/10 - 2/20/10 6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp;&lt;BR /&gt;
  set temp;&lt;BR /&gt;
y = lag(x);&lt;BR /&gt;
if date1 LE today() LE date2 then output;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
var y;&lt;BR /&gt;
run;&lt;BR /&gt;
Message was edited by: garybald&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: garybald&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: garybald

Message was edited by: garybald</description>
      <pubDate>Thu, 18 Feb 2010 20:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59541#M16793</guid>
      <dc:creator>garybald</dc:creator>
      <dc:date>2010-02-18T20:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59542#M16794</link>
      <description>My code got cut off so I changed the symbols to LE.&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: garybald

Message was edited by: garybald</description>
      <pubDate>Thu, 18 Feb 2010 20:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59542#M16794</guid>
      <dc:creator>garybald</dc:creator>
      <dc:date>2010-02-18T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59543#M16795</link>
      <description>Garybald,&lt;BR /&gt;
      Thank you for your email. I have the dates for the range as separate fields. But they are stored as numbers (like 20090801), both for the start date of the range and the end date of the range. My problem was when I use today() the ourput is a sasdate (number of days), so I don't know how to compare the date stored as numbers and the date which is number of days.&lt;BR /&gt;
&lt;BR /&gt;
Here is how I have the data &lt;BR /&gt;
&lt;BR /&gt;
range          startdate               enddate&lt;BR /&gt;
range1           20090801           20090901&lt;BR /&gt;
range2           20090902           20090930&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
range6           20100107             20100211&lt;BR /&gt;
range7           20100212             20100310&lt;BR /&gt;
&lt;BR /&gt;
and so on&lt;BR /&gt;
&lt;BR /&gt;
when I use the date function I get the output as a number&lt;BR /&gt;
date() for today 18312&lt;BR /&gt;
&lt;BR /&gt;
Can you help me compare these dates which are stored in different formats.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 19 Feb 2010 12:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59543#M16795</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-19T12:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59544#M16796</link>
      <description>Compare &lt;BR /&gt;
today() to  input(put(yourdtvar, 8.), anydtdte8.)  &lt;BR /&gt;
&lt;BR /&gt;
That should put both in SAS date form.</description>
      <pubDate>Fri, 19 Feb 2010 13:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59544#M16796</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-02-19T13:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59545#M16797</link>
      <description>Instead of reading the date in as mmddyy8. that your original post showed, use the informat to read it in as yymmdd8. which will interpret and convert the number internally to a SAS date, so the today() will work.  Just make sure that when you write the data out, use a format, so it doesn't write it out as a SAS date. If you use yymmddn8. the separators will be removed, and you will have your original number.</description>
      <pubDate>Mon, 22 Feb 2010 13:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59545#M16797</guid>
      <dc:creator>garybald</dc:creator>
      <dc:date>2010-02-22T13:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Date range question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59546#M16798</link>
      <description>Thank for all your responses, some how dates always stump me in SAS&lt;BR /&gt;
&lt;BR /&gt;
Shri</description>
      <pubDate>Tue, 23 Feb 2010 14:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-range-question/m-p/59546#M16798</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-02-23T14:10:03Z</dc:date>
    </item>
  </channel>
</rss>

