<?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: Importing a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161108#M31332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you post the log from the imported step it may help noticing how the column has been guessed by SAS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Feb 2015 15:08:22 GMT</pubDate>
    <dc:creator>Loko</dc:creator>
    <dc:date>2015-02-10T15:08:22Z</dc:date>
    <item>
      <title>Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161107#M31331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although my excel has a field in date format, SAS is importing it in Character format. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example date in excel is 12/31/2008 but its imported in SAS as 39813. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I tried following code to correct it but not getting correct date. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL noprint;&lt;/P&gt;&lt;P&gt; CREATE TABLE want AS&lt;/P&gt;&lt;P&gt; SELECT *, input('Established Date'n,ANYDTDTE22.) as new_date format=mmddyy12. &lt;/P&gt;&lt;P&gt; FROM input;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 14:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161107#M31331</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-02-10T14:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161108#M31332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you post the log from the imported step it may help noticing how the column has been guessed by SAS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161108#M31332</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2015-02-10T15:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161109#M31333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you reading in the excel spreadsheet? The code that reads spreadsheets scans the column to determine the field type.&amp;nbsp; The implication is that it is seeing mixed numeric (formatted as dates) and character data.&amp;nbsp; The 39000 number is the number of days since 1/1/1900.&amp;nbsp; If you don't have many fields , I can give you an equation to get that Ito a SAS date. Henry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161109#M31333</guid>
      <dc:creator>HenryFeldman</dc:creator>
      <dc:date>2015-02-10T15:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161110#M31334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;log doesn't give that information. Here is the log&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL noprint;&lt;/P&gt;&lt;P&gt;107&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE TABLE want AS&lt;/P&gt;&lt;P&gt;108&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *, input('Established Date'n,ANYDTDTE22.) as new_date format=mmddyy12.&lt;/P&gt;&lt;P&gt;109&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM input;&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.WANT created, with 4263 rows and 10 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUIT;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.05 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.04 seconds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161110#M31334</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-02-10T15:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161111#M31335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.1428575515747px;"&gt;I am wondering why SAS is not recognizing the date even when I set the column property in excel as date format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am importing excel using this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc import datafile='input.xls'&lt;/P&gt;&lt;P&gt;&amp;nbsp; dbms=xls out=output replace;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sheet="Profile";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 4000 rows, so can you please give me code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161111#M31335</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-02-10T15:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161112#M31336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the proc import dbms=xls code looks at the indvidual cell contents.&amp;nbsp; If a column has both numeric and character cells then it will be a character field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Excel is # of days since 1/1/1900.&amp;nbsp;&amp;nbsp; SAS is # of days since 1/1/1970.&amp;nbsp;&amp;nbsp; So if you convert the character string to a numeric and apply a date format, the number will be 70 years in the future.&amp;nbsp; The following equation needs to be applied to each date variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; numdate = input(chardate,best.) - 21915;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(BTW, if your dates still 4 years in the past, then the spreadsheet has a 1904 base date and you'll need to ADD back in 1462.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my entire test program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; chardate = "39000";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; numdate = input(chardate,best.) - 21915;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format numdate date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put numdate;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that is helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Henry&lt;/P&gt;&lt;P&gt;(developer of the sas/acccess for pc files&amp;nbsp; dbms=xls code)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161112#M31336</guid>
      <dc:creator>HenryFeldman</dc:creator>
      <dc:date>2015-02-10T15:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161113#M31337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1960 instead of 1970?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161113#M31337</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-11T17:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161114#M31338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yup 1960.&amp;nbsp;&amp;nbsp; But the correction factor is right.&amp;nbsp;&amp;nbsp; about 60 * 365&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161114#M31338</guid>
      <dc:creator>HenryFeldman</dc:creator>
      <dc:date>2015-02-11T17:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161115#M31339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is in coming in numeric or character? If character using the input method isn't likely to work as 39813 doesn't match any of the likely SAS date informats. And if you happen to have one that does look like an acceptable date it likely will convert incorrectly due to the offset used by Micro$oft.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161115#M31339</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-11T17:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161116#M31340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The 39813 is the underlying value in excel spreadsheet cell.&amp;nbsp;&amp;nbsp; (Try entering a date value and then changing the format to number.)&amp;nbsp; It is the number of days since 1/1/1900.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 17:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161116#M31340</guid>
      <dc:creator>HenryFeldman</dc:creator>
      <dc:date>2015-02-11T17:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161117#M31341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like your field is NOT being imported the way it is being 'dispayed' in excel because if it did, you'd be seeing "12/31/2008" in SAS when you display it without formatting.&lt;/P&gt;&lt;P&gt;Next, if you did use ANYDTDTE22. on this number&amp;nbsp; -39813, I would think you'd be seeing a nice little '.'&amp;nbsp; (Tested)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. &lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="862920" data-username="HenryFeldman" href="https://communities.sas.com/people/HenryFeldman" id="jive-86292039056393818061186"&gt;HenryFeldman&lt;/A&gt;&lt;/STRONG&gt;'s way&lt;/P&gt;&lt;P&gt;2. If you can, convert your excel to csv. The csv will be created with the dates actually being stored as&amp;nbsp; "12/31/2008". You can then simply use the input function on the field within SAS and it will store it as a SAS date(from 1/1/1960).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 18:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161117#M31341</guid>
      <dc:creator>PoornimaRavishankar</dc:creator>
      <dc:date>2015-02-11T18:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161118#M31342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something else to consider, especially if more than one person has worked on the spreadsheet. You may have some cells in a column that are not "formatted" the same way. And you haven't said how the data was imported.&lt;/P&gt;&lt;P&gt;I have some data I get from folks that use Excel that I have to reformat whole columns, save as CSV and then read that to have enough control to get the correct values for dates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 19:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-date/m-p/161118#M31342</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-11T19:03:42Z</dc:date>
    </item>
  </channel>
</rss>

