<?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 Bringing in date from SQL table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661850#M197796</link>
    <description>&lt;P&gt;When I run the code below, I get this error:&lt;/P&gt;&lt;P&gt;102 WHERE a.actual_date &amp;gt;= '2020-06-13T00:00:00.000';&lt;BR /&gt;ERROR: Expression using greater than or equal (&amp;gt;=) has components that are of different data types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the error is because the format on the raw table is a SQL date format, not a character or numeric variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME EVL ODBC DSN=xxx user=xxx pw=xxx schema=dbo; 

proc sql;
	create table billable_hours as
	select a.people_id
	      ,a.group_profile_id
	      ,a.actual_date
	      ,a.completed
	      ,a.end_date
	      ,a.program_providing_service_name
	      ,a.site_providing_service_name
	      ,a.event_name
	      ,a.is_service_event
	      ,a.category_name
	      ,a.generic_description
	      ,a.duration_total
	      ,a.date_entered
	      ,a.do_not_bill
	      ,a.staff_id
	      ,a.is_locked
	      ,a.date_locked
	      ,a.locked_by
	      ,a.approved_by
	      ,a.approved_date
	      ,a.category_code
	      ,a.actual_location_name
	      ,a.is_deleted
	      ,a.is_final
		  ,a.is_e_signed
	      ,a.is_billed
	      ,a.expiration_date
	      ,a.service_provider_name
	      ,a.staff_entered_event
	      ,a.general_location
	      ,a.full_name
	      ,b.activity_type_id
  FROM EVL.event_expanded_view as a
    left join EVL.service_events_view as b
		on a.event_log_id = b.event_log_id
  WHERE a.actual_date &amp;gt;= '2020-06-13T00:00:00.000';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 17 Jun 2020 17:34:04 GMT</pubDate>
    <dc:creator>ddavies</dc:creator>
    <dc:date>2020-06-17T17:34:04Z</dc:date>
    <item>
      <title>Bringing in date from SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661850#M197796</link>
      <description>&lt;P&gt;When I run the code below, I get this error:&lt;/P&gt;&lt;P&gt;102 WHERE a.actual_date &amp;gt;= '2020-06-13T00:00:00.000';&lt;BR /&gt;ERROR: Expression using greater than or equal (&amp;gt;=) has components that are of different data types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the error is because the format on the raw table is a SQL date format, not a character or numeric variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;LIBNAME EVL ODBC DSN=xxx user=xxx pw=xxx schema=dbo; 

proc sql;
	create table billable_hours as
	select a.people_id
	      ,a.group_profile_id
	      ,a.actual_date
	      ,a.completed
	      ,a.end_date
	      ,a.program_providing_service_name
	      ,a.site_providing_service_name
	      ,a.event_name
	      ,a.is_service_event
	      ,a.category_name
	      ,a.generic_description
	      ,a.duration_total
	      ,a.date_entered
	      ,a.do_not_bill
	      ,a.staff_id
	      ,a.is_locked
	      ,a.date_locked
	      ,a.locked_by
	      ,a.approved_by
	      ,a.approved_date
	      ,a.category_code
	      ,a.actual_location_name
	      ,a.is_deleted
	      ,a.is_final
		  ,a.is_e_signed
	      ,a.is_billed
	      ,a.expiration_date
	      ,a.service_provider_name
	      ,a.staff_entered_event
	      ,a.general_location
	      ,a.full_name
	      ,b.activity_type_id
  FROM EVL.event_expanded_view as a
    left join EVL.service_events_view as b
		on a.event_log_id = b.event_log_id
  WHERE a.actual_date &amp;gt;= '2020-06-13T00:00:00.000';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 17:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661850#M197796</guid>
      <dc:creator>ddavies</dc:creator>
      <dc:date>2020-06-17T17:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bringing in date from SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661852#M197797</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309196"&gt;@ddavies&lt;/a&gt;&amp;nbsp; The ODBC engine should enable SAS to manipulate data from a SQL table using SAS language functions just like a SAS dataset right?&lt;/P&gt;
&lt;P&gt;If yes, the following should do?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; WHERE datepart(a.actual_date) &amp;gt;= '13jun2020'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; And if "char"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; where datepart(input(a.actual_date),yymmdd10.) &amp;gt;= '13jun2020'd;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 17:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661852#M197797</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-17T17:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bringing in date from SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661855#M197799</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be aware, using syntax like you just suggested&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt; where datepart(input(a.actual_date),yymmdd10.) &amp;gt;= '13jun2020'd;&lt;/LI-CODE&gt;
&lt;P&gt;Would cause bad performance!&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309196"&gt;@ddavies&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would be better served using&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; WHERE a.actual_date &amp;gt;= '13jun2020'd;&lt;/LI-CODE&gt;
&lt;P&gt;The SAS/ACCESS Engine, would translate the statement to the best syntax your DataBase accepts.&lt;/P&gt;
&lt;P&gt;Check this paper for confirmation &lt;A href="https://support.sas.com/resources/papers/proceedings14/SAS039-2014.pdf" target="_blank" rel="noopener"&gt;An Insider’s Guide to SAS/ACCESS® Interface to ODBC&lt;/A&gt; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 17:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661855#M197799</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2020-06-17T17:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bringing in date from SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661856#M197800</link>
      <description>&lt;P&gt;Ah Thank you for that alert. Much appreciated! Cheers!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 17:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661856#M197800</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-17T17:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bringing in date from SQL table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661857#M197801</link>
      <description>&lt;P&gt;Thank you! This worked perfectly and with better performance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 18:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bringing-in-date-from-SQL-table/m-p/661857#M197801</guid>
      <dc:creator>ddavies</dc:creator>
      <dc:date>2020-06-17T18:00:34Z</dc:date>
    </item>
  </channel>
</rss>

