<?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: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515103#M138970</link>
    <description>&lt;P&gt;Excel stores datetime values in days with the timepart as a fraction of a day.&lt;/P&gt;
&lt;P&gt;SAS stores datetime values as seconds.&lt;/P&gt;
&lt;PRE&gt;111  data check;
112    x=18658.196296 ;
113    put x date9.;
114    dt = x*'24:00't ;
115    put dt datetime19.;
116  run;

31JAN2011
 31JAN2011:04:42:40&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Nov 2018 14:32:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-11-21T14:32:45Z</dc:date>
    <item>
      <title>Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515096#M138966</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have some date in excel&amp;nbsp; it have column date1 as&amp;nbsp;1/31/2011 4:42:40 AM&lt;/P&gt;&lt;P&gt;when imported in&amp;nbsp;SAS with format date9. it's shows as&amp;nbsp;31Jan2011&lt;/P&gt;&lt;P&gt;when I see the unformated value it's like&amp;nbsp;&amp;nbsp;18658.196296. when I query the table it does not return any record.&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;format date1 date9.;&lt;/P&gt;&lt;P&gt;input date1;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;18658.196296&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* But when I use below query the table it did not return any record*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select * from new&lt;/P&gt;&lt;P&gt;where date1="31jan2011"D;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;In Excel:&lt;/P&gt;&lt;P&gt;Data1&lt;BR /&gt;1/31/2011 4:42:40 AM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;format date1 date9.;&lt;BR /&gt;input date1;&lt;BR /&gt;datalines;&lt;BR /&gt;18658.196296&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gives:&lt;BR /&gt;date1&lt;BR /&gt;31Jan2011&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I use below query the table it did not return any record&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select * from new&lt;BR /&gt;where date1="31jan2011"D; /*datepart is also not working*/&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why this happening and how we can handle this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 14:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515096#M138966</guid>
      <dc:creator>ashutosh83</dc:creator>
      <dc:date>2018-11-21T14:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515100#M138967</link>
      <description>&lt;P&gt;At no point in your code, other than "&lt;SPAN&gt;I have some date in excel&amp;nbsp; it have column date1 as&amp;nbsp;1/31/2011 4:42:40 AM", do you mention a datetime, only dates.&amp;nbsp; Post example test data in the form of a datastep:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;There is no point in me trying to guess what you have from the post.&amp;nbsp; The steps you provide create date data.&amp;nbsp; If you want datetime then fix your import process!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 14:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515100#M138967</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-21T14:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515101#M138968</link>
      <description>It holds a fractional value&lt;BR /&gt;Filter it  &lt;BR /&gt;    &amp;gt;= '31jan2011'd and &amp;lt; '1feb2011'd</description>
      <pubDate>Wed, 21 Nov 2018 14:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515101#M138968</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-21T14:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515102#M138969</link>
      <description>&lt;PRE&gt;'31jan2011'd&lt;/PRE&gt;
&lt;P&gt;is a date value and therefore an integer (!!) count of days from 1960-01-01.&lt;/P&gt;
&lt;PRE&gt;18658.196296&lt;/PRE&gt;
&lt;P&gt;is NOT an integer value and therefore can't be equal to the above date value. Use the floor() function first.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 14:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515102#M138969</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-21T14:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515103#M138970</link>
      <description>&lt;P&gt;Excel stores datetime values in days with the timepart as a fraction of a day.&lt;/P&gt;
&lt;P&gt;SAS stores datetime values as seconds.&lt;/P&gt;
&lt;PRE&gt;111  data check;
112    x=18658.196296 ;
113    put x date9.;
114    dt = x*'24:00't ;
115    put dt datetime19.;
116  run;

31JAN2011
 31JAN2011:04:42:40&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 14:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515103#M138970</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-21T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515120#M138971</link>
      <description>&lt;P&gt;I suspect that your are not giving the right &lt;STRONG&gt;informat&lt;/STRONG&gt;&amp;nbsp; while reading the date values from Excel. You will see those decimal values if you try to read the datetime values in excel as numeric values (i.e. Informat date1 12.5 ). You may need to change the informat values to &lt;STRONG&gt;datetime26. &lt;/STRONG&gt;Read datetime values as datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have them as datetime in SAS then you have to extract date part from datetime&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where datepart(date1)="31jan2011"D&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 15:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515120#M138971</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-11-21T15:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515135#M138974</link>
      <description>&lt;P&gt;A mildly interesting side note.&amp;nbsp; The DHMS function recognizes the decimal portion and processes it accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;8    data _null_;
9       x=18658.196296;
10      put x date9.;
11      dt1 = x*'24:00't;
12      dt2 = dhms(x,0,0,0);
13      put (dt:) (/=datetime19.);
14      run;

31JAN2011

dt1=31JAN2011:04:42:40
dt2=31JAN2011:04:42:40
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 15:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515135#M138974</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-11-21T15:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515138#M138976</link>
      <description>Might be interesting to demonstrate IF there are decimal fractions of a second in the value DT1= &lt;BR /&gt;Put dt1= datetime21.2 ;</description>
      <pubDate>Wed, 21 Nov 2018 16:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515138#M138976</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-21T16:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading imported date value in SAS and using SQL to query that USing SAS EG7.1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515333#M139017</link>
      <description>&lt;P&gt;Yes while importing the file I changed the source_informat to&amp;nbsp;&lt;SPAN&gt;anydtdtew. and it resolved the issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Still not sure how it did .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input&amp;nbsp;date1 anydtdte.;&lt;BR /&gt;datalines;&lt;BR /&gt;1/31/2011 4:42:40 AM&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select&amp;nbsp;date1 as&amp;nbsp;date2 format date9. from a&lt;BR /&gt;where &lt;SPAN&gt;date1&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt; eq "31jan2011"D;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 12:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-imported-date-value-in-SAS-and-using-SQL-to-query-that/m-p/515333#M139017</guid>
      <dc:creator>ashutosh83</dc:creator>
      <dc:date>2018-11-22T12:38:56Z</dc:date>
    </item>
  </channel>
</rss>

