<?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 date comparison with charactor date constant in proc sql where clause in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509580#M72945</link>
    <description>&lt;P&gt;Best way to find out is test both.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the results for accuracy and performance i.e how fast it executes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;then take your pick&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS communities is a bufffet&lt;/P&gt;</description>
    <pubDate>Thu, 01 Nov 2018 15:51:43 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-11-01T15:51:43Z</dc:date>
    <item>
      <title>sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509546#M72939</link>
      <description>&lt;PRE&gt;I want to select records from table aa that date1 before or same
as 06-02-2018. The date1 is saved in table aa as SAS date in
format DATETIME22.3: 02JUN2018:00:00:00.000. How can I
compare these two types of date in proc SQL where clause?

Error message when ran the codes
ERROR: Expression using less than or equal (&amp;lt;=) has components that are of different data types.


data aa ;
  length date1 8; 
  input  date1;
  format date1 DATETIME22.3;
cards;
1843516800
1845244800
;;
run;

proc sql noprint; create table bb as select * from aa
where date1 eq "06-02-2018"; quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 14:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509546#M72939</guid>
      <dc:creator>nnl3256</dc:creator>
      <dc:date>2018-11-01T14:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509554#M72940</link>
      <description>&lt;P&gt;Are you after this by any chance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data aa ;
  length date1 8; 
  input  date1;
  format date1 DATETIME22.3;
cards;
1843516800
1845244800
;;
run;

proc sql noprint; create table bb as select * from aa
where datepart(date1) eq "02JUN2018"d; quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509554#M72940</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-01T15:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509560#M72941</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Are you after this by any chance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data aa ;
  length date1 8; 
  input  date1;
  format date1 DATETIME22.3;
cards;
1843516800
1845244800
;;
run;

proc sql noprint; create table bb as select * from aa
where datepart(date1) eq "02JUN2018"d; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have guessed and seen some evidence (but haven't tried to prove) that if you have very large data sets/database tables, you might be better off writing this code differently so that the datepart() function doesn't have to be evaluated on every record. Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where date1='02JUN2018:00:00:00'dt&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509560#M72941</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-01T15:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509576#M72942</link>
      <description>&lt;P&gt;That's a good point. A couple of years ago, I accidentally did something like that in-database processing with just date without the part and that worked fine. I had a SAS L account back then where I was confirmed by somebody there is a feature in SAS ACCESS that does something like that. I can't remember the real intricacy but your point rings the bell for me to look up on that&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509576#M72942</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-01T15:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509578#M72943</link>
      <description>Thank you. It wors</description>
      <pubDate>Thu, 01 Nov 2018 15:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509578#M72943</guid>
      <dc:creator>nnl3256</dc:creator>
      <dc:date>2018-11-01T15:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509579#M72944</link>
      <description>Yes, I do have a large data table. Do you suggest coding like:&lt;BR /&gt;proc sql noprint; create table bb as select * from aa&lt;BR /&gt;where date1 &amp;lt;= '02JUN2018:00:00:00'dt; quit;</description>
      <pubDate>Thu, 01 Nov 2018 15:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509579#M72944</guid>
      <dc:creator>nnl3256</dc:creator>
      <dc:date>2018-11-01T15:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: sas date comparison with charactor date constant in proc sql where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509580#M72945</link>
      <description>&lt;P&gt;Best way to find out is test both.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the results for accuracy and performance i.e how fast it executes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;then take your pick&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS communities is a bufffet&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 15:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-date-comparison-with-charactor-date-constant-in-proc-sql/m-p/509580#M72945</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-01T15:51:43Z</dc:date>
    </item>
  </channel>
</rss>

