<?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: how sas can read these dates? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33865#M6652</link>
    <description>I believe there is no solution period.  Here is why, the calendar used today is the Gregorian Calendar which came into effect in 1582 AD (hmm where have we seen that before?), which most likly why SAS uses that as the date floor.  Before the Gregorian Calendar the western world used the Julian Calendar which among other things treats leap days, number of days in a month different than the calendar used today.  Hence a monday could be a tuesday if you compare a Julian date with a Gregorian date and the year could have a different number of days.&lt;BR /&gt;
&lt;BR /&gt;
Gregorian dates before 1582 use something called the  proleptic Gregorian calendar.  Unfortunately, I don't SAS can use that calendar (there may be a custom calendar functionality but I don't know about it) Since SAS dates will not go before 1582, you will have to find a custom solution.&lt;BR /&gt;
&lt;BR /&gt;
My first suggestion would be to find Julian day number to Gregorian mapping table (GOOGLE it and see what you find) and treat the days as integers and not dates.  A Julian day number is not the same thing as the Julian Calendar it is the number days since 1/14713 BC, not sure why that day was picked .   You will have to construct your own "date" format to display it.  Just a guess, I haven't tried to go that far back in time with SAS.  &lt;BR /&gt;
&lt;BR /&gt;
I wish I could be more helpful.  &lt;BR /&gt;
-Darryl</description>
    <pubDate>Fri, 25 Jul 2008 11:55:45 GMT</pubDate>
    <dc:creator>darrylovia</dc:creator>
    <dc:date>2008-07-25T11:55:45Z</dc:date>
    <item>
      <title>how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33862#M6649</link>
      <description>data san; &lt;BR /&gt;
input @ 1 from_dt date9. @ 11  to_date date10. ; &lt;BR /&gt;
cards ; &lt;BR /&gt;
01jan1382 01jan20001 &lt;BR /&gt;
01jan1082 01dec20001 &lt;BR /&gt;
01jan1882 01jan20000 &lt;BR /&gt;
01jan1582 01jan2001 &lt;BR /&gt;
; &lt;BR /&gt;
run ;</description>
      <pubDate>Thu, 24 Jul 2008 08:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33862#M6649</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-07-24T08:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33863#M6650</link>
      <description>I think that you are SOL.  From the SAS Base documentation:&lt;BR /&gt;
&lt;BR /&gt;
SAS date value&lt;BR /&gt;
is a value that represents the number of days between January 1, 1960, and a&lt;BR /&gt;
specified date. SAS can perform calculations on dates ranging from A.D. 1582 to&lt;BR /&gt;
A.D. 19,900.&lt;BR /&gt;
&lt;BR /&gt;
The reason for this is that, when the dates are stored as durations, that range is the widest that can be precisely expressed in real number format in 8 bytes.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Thu, 24 Jul 2008 12:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33863#M6650</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2008-07-24T12:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33864#M6651</link>
      <description>i know this !&lt;BR /&gt;
but for my one of the project i have to play with such type of dates.&lt;BR /&gt;
now how can i handle this?&lt;BR /&gt;
&lt;BR /&gt;
no solution in sas?</description>
      <pubDate>Fri, 25 Jul 2008 05:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33864#M6651</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-07-25T05:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33865#M6652</link>
      <description>I believe there is no solution period.  Here is why, the calendar used today is the Gregorian Calendar which came into effect in 1582 AD (hmm where have we seen that before?), which most likly why SAS uses that as the date floor.  Before the Gregorian Calendar the western world used the Julian Calendar which among other things treats leap days, number of days in a month different than the calendar used today.  Hence a monday could be a tuesday if you compare a Julian date with a Gregorian date and the year could have a different number of days.&lt;BR /&gt;
&lt;BR /&gt;
Gregorian dates before 1582 use something called the  proleptic Gregorian calendar.  Unfortunately, I don't SAS can use that calendar (there may be a custom calendar functionality but I don't know about it) Since SAS dates will not go before 1582, you will have to find a custom solution.&lt;BR /&gt;
&lt;BR /&gt;
My first suggestion would be to find Julian day number to Gregorian mapping table (GOOGLE it and see what you find) and treat the days as integers and not dates.  A Julian day number is not the same thing as the Julian Calendar it is the number days since 1/14713 BC, not sure why that day was picked .   You will have to construct your own "date" format to display it.  Just a guess, I haven't tried to go that far back in time with SAS.  &lt;BR /&gt;
&lt;BR /&gt;
I wish I could be more helpful.  &lt;BR /&gt;
-Darryl</description>
      <pubDate>Fri, 25 Jul 2008 11:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33865#M6652</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2008-07-25T11:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33866#M6653</link>
      <description>Hi:&lt;BR /&gt;
  Oh, my, I had NO idea there was this much possibility of variation in dates. These make for interesting reading and the last link has a formula and some lookup tables.&lt;BR /&gt;
&lt;A href="http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html" target="_blank"&gt;http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://charon.nmsu.edu/~lhuber/leaphist.html" target="_blank"&gt;http://charon.nmsu.edu/~lhuber/leaphist.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.decimaltime.hynes.net/dates.html" target="_blank"&gt;http://www.decimaltime.hynes.net/dates.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.decimaltime.hynes.net/convert.html" target="_blank"&gt;http://www.decimaltime.hynes.net/convert.html&lt;/A&gt; (has a Gregorian to Julian conversion formula)&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 25 Jul 2008 20:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33866#M6653</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-07-25T20:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33867#M6654</link>
      <description>Hi Pavan.&lt;BR /&gt;
I would try something quite different : store separately day, month &amp;amp; year instead of trying to build a real date. You can compute durations (though it will be a little more complicated that using built-in SAS function) but usually this is enough to get trhough common needs.&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format ;&lt;BR /&gt;
	invalue months&lt;BR /&gt;
		"jan" = 1&lt;BR /&gt;
		"feb" = 2&lt;BR /&gt;
		"mar" = 3&lt;BR /&gt;
		"apr" = 4 /* and so on */&lt;BR /&gt;
		"dec" = 12&lt;BR /&gt;
	;&lt;BR /&gt;
run ;&lt;BR /&gt;
data san; &lt;BR /&gt;
input @1 from_dd 2. from_mm months. from_yy 4. @11 to_dd 2. to_mm months. to_yy :5. ; &lt;BR /&gt;
cards ; &lt;BR /&gt;
01jan1382 01jan20001 &lt;BR /&gt;
01jan1082 01dec20001 &lt;BR /&gt;
01jan1882 01jan20000 &lt;BR /&gt;
01jan1582 01jan2001 &lt;BR /&gt;
; &lt;BR /&gt;
run ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Sun, 27 Jul 2008 09:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33867#M6654</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-07-27T09:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33868#M6655</link>
      <description>by using this, i can read this dates into sas.&lt;BR /&gt;
but to do some analysis like date difference and something, how i can do?&lt;BR /&gt;
if these dates will enter into sas dataset, like numer of dates from 1jan1960,&lt;BR /&gt;
then it is good to do some analysis!&lt;BR /&gt;
&lt;BR /&gt;
i want to take these dates as no. of days from 1jan1960.</description>
      <pubDate>Mon, 28 Jul 2008 05:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33868#M6655</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-07-28T05:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33869#M6656</link>
      <description>i got the solution !&lt;BR /&gt;
&lt;BR /&gt;
data san; &lt;BR /&gt;
length from_dt to_date $10;&lt;BR /&gt;
input from_dt $ : to_date $ : ; &lt;BR /&gt;
if input(substr(from_dt,6),best.) lt 1582 then do;&lt;BR /&gt;
    days_in_loop=0;&lt;BR /&gt;
      days_till_1582='01jan1582'd;&lt;BR /&gt;
      do i=input(substr(from_dt,6),best.) to 1581;&lt;BR /&gt;
            if mod(i,4)=0 then days_in_year=366;&lt;BR /&gt;
            else days_in_year=365;&lt;BR /&gt;
            days_in_loop=days_in_loop-days_in_year;&lt;BR /&gt;
      end;&lt;BR /&gt;
      from_dt1=days_till_1582+days_in_loop;&lt;BR /&gt;
end;&lt;BR /&gt;
else from_dt1=input(from_dt,date9.);&lt;BR /&gt;
to_date1=input(tranwrd(to_date,'000','00'),date9.);&lt;BR /&gt;
keep to: from: ;&lt;BR /&gt;
cards ; &lt;BR /&gt;
01jan1382 01jan20001 &lt;BR /&gt;
01jan1082 01dec20001 &lt;BR /&gt;
01jan1882 01jan20000 &lt;BR /&gt;
01jan1582 01jan2001 &lt;BR /&gt;
01jan1581 01jan20003&lt;BR /&gt;
; &lt;BR /&gt;
run ;</description>
      <pubDate>Mon, 28 Jul 2008 09:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33869#M6656</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-07-28T09:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33870#M6657</link>
      <description>Your leepyear algorithm is too crude - it is not simply every 4 years. Can't recall the exact rules, but did code it up once. A quick google should help you out</description>
      <pubDate>Wed, 15 Oct 2008 11:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33870#M6657</guid>
      <dc:creator>jbhan</dc:creator>
      <dc:date>2008-10-15T11:24:45Z</dc:date>
    </item>
    <item>
      <title>how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33871#M6658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Leapyears are every four years EXCEPT for century years which are only leapyears if they are divisible by 400. So, 2012 is a leap year (divisible by 4), 1900 was not a leapyear (it was a century year but was not divisible by 400), 2000 was a leapyear (century year divisible by 400).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 15:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33871#M6658</guid>
      <dc:creator>DouglasMartin</dc:creator>
      <dc:date>2011-08-04T15:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: how sas can read these dates?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33872#M6659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although --- this is a bit off topic by now, since I'm fairly certain that &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://communities.sas.com/people/darrylovia" id="jive-35783913046971410073803"&gt;darrylovia&lt;/A&gt;'s answer means that treating the days before 1582 as if they came from current-day calendar practices is essentially wrong ... I thought I'd share my leap year code logic (operates on the year in four digits ... so you'd need to get the year from the SAS date value first):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* The following is the beginning snippet of code that defines a year as a leap year */ &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF (MOD(YEAR,100) NE 0 AND MOD(YEAR,4) EQ 0) OR (MOD(YEAR,400) EQ 0) THEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... I think this handles when leap years occur in the modern calendar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 16:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-sas-can-read-these-dates/m-p/33872#M6659</guid>
      <dc:creator>AllenEBingham</dc:creator>
      <dc:date>2011-08-05T16:04:11Z</dc:date>
    </item>
  </channel>
</rss>

