<?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: Convert sas date to actual date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519151#M140571</link>
    <description>&lt;P&gt;So when I put the numbers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;41089&lt;/P&gt;&lt;P&gt;41059&lt;/P&gt;&lt;P&gt;41212&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in Microsoft Excel it gives me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;06/29/12&lt;/P&gt;&lt;P&gt;05/30/12&lt;/P&gt;&lt;P&gt;10/30/12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but sas gave&amp;nbsp;me &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;11JUN72&lt;/P&gt;&lt;P&gt;21MAY72&lt;/P&gt;&lt;P&gt;29OCT72&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I am pulling from has the following properties:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type Numeric&lt;/P&gt;&lt;P&gt;Group Numeric&lt;/P&gt;&lt;P&gt;Format 11.&lt;/P&gt;&lt;P&gt;Informat 11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 15:16:07 GMT</pubDate>
    <dc:creator>asherer</dc:creator>
    <dc:date>2018-12-06T15:16:07Z</dc:date>
    <item>
      <title>Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519146#M140568</link>
      <description>&lt;P&gt;I am trying to convert a sas date field to a regular date field in PROC SQL.... The field name is DateID_TransactionDate... The data&amp;nbsp; looks like this before running the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DateID_TransactionDate&lt;/P&gt;&lt;P&gt;41089&lt;/P&gt;&lt;P&gt;41059&lt;/P&gt;&lt;P&gt;41212&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I am using is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; WORK.QUERY_FOR_WAIVEREFUND_FACT &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.DateID_TransactionDate FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;DATE7.&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DateID_TransactionDate, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SQL_LIB.WaiveRefund_Fact t1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results I am getting is&lt;/P&gt;&lt;P&gt;11JUN72&lt;/P&gt;&lt;P&gt;21MAY72&lt;/P&gt;&lt;P&gt;29OCT72&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These dates are incorrect and here is what I want it to show:&lt;/P&gt;&lt;P&gt;06/29/12&lt;/P&gt;&lt;P&gt;05/30/12&lt;/P&gt;&lt;P&gt;10/30/12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519146#M140568</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2018-12-06T15:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519147#M140569</link>
      <description>&lt;P&gt;I don't see how you would get the desired dates from those values? Please elaborate. Putting the desired format on them creates this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input DateID_TransactionDate;
format DateID_TransactionDate mmddyy8.;
datalines;
41089
41059
41212
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519147#M140569</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-06T15:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519151#M140571</link>
      <description>&lt;P&gt;So when I put the numbers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;41089&lt;/P&gt;&lt;P&gt;41059&lt;/P&gt;&lt;P&gt;41212&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in Microsoft Excel it gives me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;06/29/12&lt;/P&gt;&lt;P&gt;05/30/12&lt;/P&gt;&lt;P&gt;10/30/12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but sas gave&amp;nbsp;me &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;11JUN72&lt;/P&gt;&lt;P&gt;21MAY72&lt;/P&gt;&lt;P&gt;29OCT72&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I am pulling from has the following properties:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type Numeric&lt;/P&gt;&lt;P&gt;Group Numeric&lt;/P&gt;&lt;P&gt;Format 11.&lt;/P&gt;&lt;P&gt;Informat 11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519151#M140571</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2018-12-06T15:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519157#M140573</link>
      <description>&lt;P&gt;it seems that the numbers are based off total time from 01/01/1900 (Excel Start Time).. What would be a formula to fix it.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519157#M140573</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2018-12-06T15:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519167#M140576</link>
      <description>&lt;P&gt;Excel uses the data value 1 for 01jan1900, 2for 02jan190o, etc.&amp;nbsp; But SAS uses 1 for 02jan1960.&amp;nbsp; So for an excel data value, you presumably have to subtract a number equal to '02jan1960'd - '01jan1900'd = 21915.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EXCEPT&amp;nbsp; !!!&amp;nbsp;&amp;nbsp; Even though 1900 is divisible by 4, there is no leap day in the Gregorian calendar for 1900.&amp;nbsp; But excel erroneously assumes there is (the putative reason was to be consistent with this error introduced in the earlier Lotus 1-2-3 spreadsheet).&amp;nbsp; So the shift in values has to be increased by 1 to accurately shift from excel date value to sas date value:&amp;nbsp; i.e. '02jan1960'd-'31dec1899'd=21916:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do xval=41089,41059,41212;
    sval=xval-21916;
    put  xval= sval= sval=date9.;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But be aware that, because Excel doesn't have 29feb1900, this rule only works for date on or after 01mar1900. &lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519167#M140576</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T15:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519211#M140588</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221781"&gt;@asherer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to convert a sas date field to a regular date field in PROC SQL.... The field name is DateID_TransactionDate... The data&amp;nbsp; looks like this before running the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DateID_TransactionDate&lt;/P&gt;
&lt;P&gt;41089&lt;/P&gt;
&lt;P&gt;41059&lt;/P&gt;
&lt;P&gt;41212&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I am using is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; WORK.QUERY_FOR_WAIVEREFUND_FACT &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.DateID_TransactionDate FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;DATE7.&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DateID_TransactionDate, &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SQL_LIB.WaiveRefund_Fact t1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results I am getting is&lt;/P&gt;
&lt;P&gt;11JUN72&lt;/P&gt;
&lt;P&gt;21MAY72&lt;/P&gt;
&lt;P&gt;29OCT72&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These dates are incorrect and here is what I want it to show:&lt;/P&gt;
&lt;P&gt;06/29/12&lt;/P&gt;
&lt;P&gt;05/30/12&lt;/P&gt;
&lt;P&gt;10/30/12&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And you have just demonstrated a version of the Y2K issue: 2 digit years. If at all practical do not use two digit years. The 41089 would have shown as 30JUN2072 if you had used DATE9. and 4 digit years. Which would have shown that some VERY significant was going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recognized this as a likely Excel date issue as we have seen that many times. You can usually get better results with dates by ensuring that an entire column is formatted as the desired date appearance in Excel and then exporting the data from Excel as CSV and reading that file into SAS. Then SAS would have been reading from a field like 06/29/2012 to start with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 16:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519211#M140588</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-06T16:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519242#M140604</link>
      <description>&lt;P&gt;So if I run the numbers the way you have it, it works... but if I try to proc SQL its not working any suggestion...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; WORK.QUERY_FOR_WAIVEREFUND_FACT &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; t1.DateID_TransactionDate-21916 FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;DATE7.&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DateID_TransactionDate, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SQL_LIB.WaiveRefund_Fact t1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519242#M140604</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2018-12-06T19:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519244#M140606</link>
      <description>&lt;P&gt;What am I supposed to understand from the phrase "its not working"?&amp;nbsp;&amp;nbsp; Please show what you expected, and what you got.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, BTW, you are apparently extracting data from SQL.&amp;nbsp; Does it contain the excel data values?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519244#M140606</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T19:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sas date to actual date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519247#M140608</link>
      <description>&lt;P&gt;Sorry I should of gave you more info than previously. Odd thing is after you wrote me back I has exited out and retried and its working... Sorry for saying it did not work. And thanks so much for the help... I must of had a typo.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 19:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-sas-date-to-actual-date/m-p/519247#M140608</guid>
      <dc:creator>asherer</dc:creator>
      <dc:date>2018-12-06T19:29:54Z</dc:date>
    </item>
  </channel>
</rss>

