BookmarkSubscribeRSS Feed
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

I have two tables that have the same type and format for both dates. My code is this:

PROC SQL;

CREATE TABLE ReAdm.Sum2010 AS

(SELECT DISTINCT

A.MBR_SYS_ID,

A.TIN,

A.FST_SRVC_DT,

A.READMIT,

B.ALLOWED_AMT,

B.ADMIT_DT,

B.DISCH_DT,

B.CUTPUT_DT,

B.START_DT,

B.STAT_DAY,

B.START_DT2,

B.READMIT_DT,

B.REDISCH_DT,

B.CUTPUT_DT2

FROM ReAdm.ReAdm1 A

LEFT JOIN ReAdm.Cleaning3 B

ON A.MBR_SYS_ID = B.MBR_SYS_ID

AND

A.TIN = B.TIN

WHERE

A.FST_SRVC_DT BETWEEN ('01-01-2010') AND ('12-31-2010') AND

A.READMIT >=1 AND B.START_DT2 IS NOT NULL);

RUN;

If I take the date items out it runs fine but putting the date stuff in I get this error:

ERROR: Expression using IN has components that are of different data types.

NOTE: The IN referred to may have been transformed from an OR to an IN at some point during PROC

      SQL WHERE clause optimization.

449  RUN;

NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.

3 REPLIES 3
ballardw
Super User

If the FST_SRVC_DT variable are SAS dates then you are comparing a numeric to a string '01-01'2010'.

If these are SAS date values you want to reference date literals as '01JAN2010'd and '31DEC201'd

PGStats
Opal | Level 21

Change the way you represent datetime litterals:

WHERE

A.FST_SRVC_DT BETWEEN ('01-01-2010') AND ('12-31-2010') AND

for proper datetime constants:

WHERE

A.FST_SRVC_DT BETWEEN '01JAN2010:00:00:00'dt AND '31DEC2010:23:59:59'dt AND

or, if those are date variables (despite the DT in the name)

WHERE

A.FST_SRVC_DT BETWEEN '01JAN2010'd AND '31DEC2010'd AND

PG

PG
QLi
Fluorite | Level 6 QLi
Fluorite | Level 6

Check the informat  of FST_SRVC_DT

and try  this condition.

WHERE   year (A.FST_SRVC_DT BETWEEN)=2010

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1562 views
  • 0 likes
  • 4 in conversation