<?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: SAS Dates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315644#M61655</link>
    <description>&lt;P&gt;Please post few lines with relevant varaibles only from the excel and explain, better by wanted output, what do you want.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2016 19:27:36 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-11-30T19:27:36Z</dc:date>
    <item>
      <title>SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315639#M61653</link>
      <description>&lt;P&gt;How do I convert serial Numbers within raw data into regular dates within SAS? I have an excel spreadsheet that has most of its dates as serial numbers rather than general dates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315639#M61653</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T19:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315644#M61655</link>
      <description>&lt;P&gt;Please post few lines with relevant varaibles only from the excel and explain, better by wanted output, what do you want.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315644#M61655</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T19:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315648#M61656</link>
      <description>&lt;P&gt;Wanted Variable to be corrected Trap_Coll_Date;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;---&amp;gt; 41503 is stored in excel, but it represents 8/17/2016&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some dates are stored as serial numbers, some dates are stored as regular dates&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can convert the serial numbers in excel into dates, but importing it to SAS reveals the original serial number from Excel. How to I fix this ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315648#M61656</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T19:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315650#M61658</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean you are seeing values like 40123 in the spreadsheet that may represent 11/6/2009?&lt;/P&gt;
&lt;P&gt;It may be as simple as setting the column to display as a date in Excel using the FORMAT Cells options.&lt;/P&gt;
&lt;TABLE width="68"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="68"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315650#M61658</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-30T19:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315654#M61659</link>
      <description>&lt;P&gt;Assign excel cells format to display dates, then close and save the excel with its new format.&lt;/P&gt;
&lt;P&gt;Import the excel only when closed.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315654#M61659</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T19:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315656#M61660</link>
      <description>&lt;P&gt;Yes it appears like that, I've tried using the format options to convert the serial numbers to dates.&lt;/P&gt;&lt;P&gt;The problem is not all the dates &amp;nbsp;were imputed into Excel as serial numbers. Some values appear&amp;nbsp;as dates when formated options were changed from date to general.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the SAS output after importing the excel file&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 19:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315656#M61660</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T19:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315658#M61661</link>
      <description>&lt;P&gt;Specifcally looking at the dates column, you will find that some of the output is in serial number format and some show actual dates.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315658#M61661</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T20:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315664#M61663</link>
      <description>&lt;P&gt;Maybe you just need add sas format to the date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;format date date9. ;&lt;/STRONG&gt; &amp;nbsp;/* or ddmmyy10. or mmddyy10. or any other available date format */&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315664#M61663</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T20:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315669#M61664</link>
      <description>&lt;P&gt;Alright, what is the procedure to adjust dates within excel spread sheets in sas&amp;nbsp;&lt;/P&gt;&lt;P&gt;do I type an informat line&amp;nbsp;before typing a format ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315669#M61664</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315672#M61665</link>
      <description>&lt;P&gt;What is your code to import the excel ?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315672#M61665</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T20:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315676#M61666</link>
      <description>&lt;P&gt;My Code-&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile="C:\Users\okund\Desktop\Practicum Documents\2016MosqDataEntry.xlsx"&lt;BR /&gt;out=Grad.mosdata&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;getnames=yes;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315676#M61666</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T20:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315680#M61667</link>
      <description>&lt;P&gt;I'm not sure you can add the date format in PROC IMPORT.&lt;/P&gt;
&lt;P&gt;So just add next code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; proc import ..... &amp;nbsp;&amp;nbsp;/* your code as is */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;out=&lt;STRONG&gt;Grad.mosdata&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ... &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; proc datasets lib=&lt;STRONG&gt;grad&lt;/STRONG&gt; nolist;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; modify&amp;nbsp;&lt;STRONG&gt;mosdata;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; format date date9.; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;/* or any other SAS date format */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;run; quit;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315680#M61667</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T20:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315682#M61668</link>
      <description>check the dates that are correct as in excel</description>
      <pubDate>Wed, 30 Nov 2016 20:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315682#M61668</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T20:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315690#M61669</link>
      <description>&lt;P&gt;I used the code you sent me, and sas Log stated this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1320 proc datasets lib=grad nolist;&lt;BR /&gt;1321 modify mosdata;&lt;BR /&gt;ERROR: You are trying to use the numeric format DATE with the character variable trap_coll_date in&lt;BR /&gt;data set GRAD.MOSDATA.&lt;BR /&gt;1322 format Trap_Coll_Date date9.; /* or any other SAS date format */&lt;BR /&gt;1323 run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is this because sas is reading dates as a character variabel instead of a numberic variable ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 20:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315690#M61669</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T20:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315691#M61670</link>
      <description>&lt;P&gt;Also why is SAS reading Date as a character variable ?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 21:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315691#M61670</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T21:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315695#M61671</link>
      <description>&lt;P&gt;The internal SAS value for 1/1/1960 is 0.&amp;nbsp; The internal excel value for the same date is 21,916.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So after importing to SAS, you could&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Subtract 21916 from the improperly imported date values.&lt;/LI&gt;
&lt;LI&gt;Assign a SAS format to the variable.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;This will work as long as you have no dates preceding Mar 1, 1900.&amp;nbsp; That's because visicalc mistakenly thought that 1900 was a leap year - an error preserved in its successor excel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mk&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 21:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315695#M61671</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-30T21:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315698#M61672</link>
      <description>&lt;P&gt;It seems that not all cells of the column are defined as numeric.&lt;/P&gt;
&lt;P&gt;Maybe in some rows the cells are defined as text.&lt;/P&gt;
&lt;P&gt;In such case you need convert the text into numeric and make it as date format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; set have(rename=(date=datex));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if lengthn(datex) = 5 then date = input(datex,5.);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else date = input(datex, mmddyy10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;format date date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in case the dates in sas does not fit to the equivalent date of serial number of execl&lt;/P&gt;
&lt;P&gt;you will need addapt it by a fix number of days.&lt;/P&gt;
&lt;P&gt;SAS date count days since 01JAN1960 (serial number = 0);&lt;/P&gt;
&lt;P&gt;while in excel 0 is: 00JAN1900&lt;/P&gt;
&lt;P&gt;which means a difference of 21916 days.&lt;/P&gt;
&lt;P&gt;Then change line to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;if lengthn(datex) = 5 then date = input(datex,5.) - 21916 ;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 21:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315698#M61672</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-30T21:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315717#M61673</link>
      <description>&lt;P&gt;It kind of worked, the years for the respective serial numbers came out as follows&amp;nbsp;&lt;/P&gt;&lt;P&gt;----&amp;gt; 2013 = 2073&lt;/P&gt;&lt;P&gt;----&amp;gt; 2015 = 2075&amp;nbsp;&lt;/P&gt;&lt;P&gt;----&amp;gt; 2016 = 2076&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 22:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315717#M61673</guid>
      <dc:creator>Okundaye1</dc:creator>
      <dc:date>2016-11-30T22:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315719#M61674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117559"&gt;@Okundaye1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Also why is SAS reading Date as a character variable ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because you have some of the data entered as text that Excel did not treat as a date when entered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution I have had to this is generally: 1) make sure the column is formatted as a consistent date format in Excel. 2) Export the data to CSV 3) read with an appropriate INFORMAT. If the data is relatively clean then that Informat may be mmddyy10. or similar. Sometimes Anydtdte32.&lt;/P&gt;
&lt;P&gt;And then 4) beat the data source about the head and shoulders with a wet noodle about poorly entered data. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 22:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315719#M61674</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-30T22:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315804#M61676</link>
      <description>did you use:&lt;BR /&gt;  if lengthn(datex) = 5 then date = input(datex,5.) - 21916 ;</description>
      <pubDate>Thu, 01 Dec 2016 04:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Dates/m-p/315804#M61676</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-01T04:12:00Z</dc:date>
    </item>
  </channel>
</rss>

