BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ddavies
Calcite | Level 5

When I run the code below, I get this error:

102 WHERE a.actual_date >= '2020-06-13T00:00:00.000';
ERROR: Expression using greater than or equal (>=) has components that are of different data types.

 

I believe the error is because the format on the raw table is a SQL date format, not a character or numeric variable. 

 

Suggestions?

 

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 >= '2020-06-13T00:00:00.000';
quit;
1 ACCEPTED SOLUTION

Accepted Solutions
AhmedAl_Attar
Ammonite | Level 13

@novinosrin 

 

Be aware, using syntax like you just suggested

 where datepart(input(a.actual_date),yymmdd10.) >= '13jun2020'd;

Would cause bad performance!

@ddavies 

You would be better served using

 WHERE a.actual_date >= '13jun2020'd;

The SAS/ACCESS Engine, would translate the statement to the best syntax your DataBase accepts.

Check this paper for confirmation An Insider’s Guide to SAS/ACCESS® Interface to ODBC  

 

Hope this helps,

Ahmed 

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Hi @ddavies  The ODBC engine should enable SAS to manipulate data from a SQL table using SAS language functions just like a SAS dataset right?

If yes, the following should do?

 WHERE datepart(a.actual_date) >= '13jun2020'd;

  And if "char"

 where datepart(input(a.actual_date),yymmdd10.) >= '13jun2020'd;
AhmedAl_Attar
Ammonite | Level 13

@novinosrin 

 

Be aware, using syntax like you just suggested

 where datepart(input(a.actual_date),yymmdd10.) >= '13jun2020'd;

Would cause bad performance!

@ddavies 

You would be better served using

 WHERE a.actual_date >= '13jun2020'd;

The SAS/ACCESS Engine, would translate the statement to the best syntax your DataBase accepts.

Check this paper for confirmation An Insider’s Guide to SAS/ACCESS® Interface to ODBC  

 

Hope this helps,

Ahmed 

novinosrin
Tourmaline | Level 20

Ah Thank you for that alert. Much appreciated! Cheers!

ddavies
Calcite | Level 5

Thank you! This worked perfectly and with better performance! 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 653 views
  • 1 like
  • 3 in conversation