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

Hi!!

I have three tables:

ODS.DATE (SAS TABLE) - Column DATE (numeric 😎 format DATETIME20.

ODS.CUSTOMER (SAS TABLE) - Column ID (numeric 😎

ORA.CUSTOMER (ORACLE TABLE) - Column ID (number), Column DAT (date)

I need to run this code:

PROC SQL NOPRINT;

select date into :LOAD_DATE from ODS.DATE

QUIT;

proc sql;

connect to oracle as conn (path='XXXX' user=XXXXX password="XXXXX");

insert into ODS.CUSTOMER

select ID from connection to conn (

     select ID from ORA.CUSTOMER where dat >= "&LOAD_DATE"

);

disconnect from conn;

quit;

The following error is occurring:

- ERROR: ORACLE prepare error: ORA-00904: " 01JAN1900:00:00:00": invalid identifier. SQL statement: select * from ORA.CUSTOMER where dat >= " 01JAN1900:00:00:00".

Does anyone know how I Can pass the parameter correctly for Oracle?

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

Where clauses are usually pushed to Oracle using implicit pass-thru, the SAS/ACCESS engine will translate the date constant for you.

You need to add a format specification in the select into: clause (date9. - given this is a SAS date), and add a d when you refer to it: "&LOAD_DATE"d

Data never sleeps

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20

Where clauses are usually pushed to Oracle using implicit pass-thru, the SAS/ACCESS engine will translate the date constant for you.

You need to add a format specification in the select into: clause (date9. - given this is a SAS date), and add a d when you refer to it: "&LOAD_DATE"d

Data never sleeps
Tom
Super User Tom
Super User

Here is a link to Oracle documentation on datetime literals. Literals  Example: DATE '1998-12-25'

(Note that unlike SAS Oracle only has DATETIME and does not have separate DATE type).

select cats("DATE '",put(datepart(date),YYMMDD10.),"'") into :LOAD_DATE from ODS.DATE

...

select ID from connection to conn (

     select ID from ORA.CUSTOMER where dat >= &LOAD_DATE

)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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