<?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: Change the date format (weird data) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654580#M22546</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329937"&gt;@takpdpb7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reference date used in Excel is 01JAN1900.&lt;/P&gt;
&lt;P&gt;12649 formatted in Excel results in this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-06-08 à 18.26.53.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40920iC45364714A4F280C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-06-08 à 18.26.53.png" alt="Capture d’écran 2020-06-08 à 18.26.53.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;In SAS, the reference date is different: it is actually 01JAN1960.&lt;/P&gt;
&lt;P&gt;One way to handle the problem is to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date = "30DEC1899"d + 12649;
format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 16:42:00 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-06-08T16:42:00Z</dc:date>
    <item>
      <title>Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654577#M22545</link>
      <description>&lt;P&gt;I extracted a dataset and in the database, the DOB is showing normally for all individuals (01/01/2000), but in the excel extract, the date is showing as a series of numbers, like 111111. For example, the DOB for one individual is 08/18/1934, but in the excel extract, it is 12649. I'm not seeing any correlation between the two numbers. What date format could I do to correct this in SAS?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 15:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654577#M22545</guid>
      <dc:creator>takpdpb7</dc:creator>
      <dc:date>2020-06-08T15:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654580#M22546</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329937"&gt;@takpdpb7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reference date used in Excel is 01JAN1900.&lt;/P&gt;
&lt;P&gt;12649 formatted in Excel results in this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-06-08 à 18.26.53.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40920iC45364714A4F280C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-06-08 à 18.26.53.png" alt="Capture d’écran 2020-06-08 à 18.26.53.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;In SAS, the reference date is different: it is actually 01JAN1960.&lt;/P&gt;
&lt;P&gt;One way to handle the problem is to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
date = "30DEC1899"d + 12649;
format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 16:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654580#M22546</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-08T16:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654581#M22547</link>
      <description>&lt;P&gt;What happens if you take the number in Excel and apply a date format to it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most applications actually store dates and times as numbers and then apply a display format to show it as a time. So what you're seeing is likely the unformatted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, how you export your data to Excel matters. How are you doing that step? PROC EXPORT doesn't typically write labels and formats by default but ODS EXCEL does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='/folders/myfolders/demo.xlsx';

proc print data=sashelp.stocks;
where stock = 'IBM';
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329937"&gt;@takpdpb7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I extracted a dataset and in the database, the DOB is showing normally for all individuals (01/01/2000), but in the excel extract, the date is showing as a series of numbers, like 111111. For example, the DOB for one individual is 08/18/1934, but in the excel extract, it is 12649. I'm not seeing any correlation between the two numbers. What date format could I do to correct this in SAS?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 16:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654581#M22547</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-08T16:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654590#M22550</link>
      <description>&lt;P&gt;You need to more clearly specify what you did to get a detailed answer.&amp;nbsp; But the number you are seeing looks like how Excel would normally store that date when it is using the default base year of 1900.&amp;nbsp; In SAS that number would be the date 19AUG1994.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1950  data _null_;
1951    have=12649 ;
1952    sasdate=have + '30DEC1899'd ;
1953    put (2*have 2*sasdate) (= comma. date9. /);
1954  run;

have=12,649 19AUG1994
sasdate=-9,267 18AUG1934
&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jun 2020 16:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654590#M22550</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-08T16:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654596#M22553</link>
      <description>&lt;P&gt;Go to the Excel file, highlight the column and change the data type to one of the date formats you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel starts counting dates at 1 Jan 1900 and that is likely to be the number of days since that day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this Excel file output from SAS or something you read? If it is output you should show us how you are creating the output to see if we can make this "transparent", not an additional step.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 16:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654596#M22553</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-08T16:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654597#M22554</link>
      <description>&lt;P&gt;I just used the export function on the database I am working with and the raw data was showing 12649. I then used proc import to bring the dataset into SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import out=BAB&lt;BR /&gt;datafile="path"&lt;BR /&gt;dbms=excel&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 16:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654597#M22554</guid>
      <dc:creator>takpdpb7</dc:creator>
      <dc:date>2020-06-08T16:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654622#M22557</link>
      <description>&lt;P&gt;Are you having issues displaying your data in Excel or after you've imported it to SAS from Excel and are trying to work with it in SAS?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 17:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654622#M22557</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-08T17:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Change the date format (weird data)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654623#M22558</link>
      <description>Ideally you would connect SAS directly do your DB so you avoid any data type issues when importing/exporting the data.</description>
      <pubDate>Mon, 08 Jun 2020 17:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Change-the-date-format-weird-data/m-p/654623#M22558</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-08T17:27:23Z</dc:date>
    </item>
  </channel>
</rss>

