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

Hello,

 

Sorry I am new to using SAS fulltime, however come with a solid SQL skillset. 

 

Issue: I need to pass a date in the WHERE statement in an ORACLE Passthrough (Explicit) SQL Query. The date is a Macro field. 

 

Below is the statement: 

 

EXPRTN_DT > TO_DATE(&END_DATE,'DDMONYYYY') 

 

In SAS, &END_DATE has a value of 31MAR2017. (Edit1: Without quotes and this macro is generated dynamically from SAS SQL using INTO: Function)

 

Steps tried other than the one mentioned above:

1. EXPRTN_DT > TO_DATE("&END_DATE",'DDMONYYYY') 

2. EXPRTN_DT > TO_DATE('&END_DATE','DDMONYYYY') 

3. EXPRTN_DT > TO_DATE('''&END_DATE''','DDMONYYYY')  /*Note: Single Quotes surrounded by Single Quotes)*/

4. EXPRTN_DT > &END_DATE

5. EXPRTN_DT > "&END_DATE"

6. EXPRTN_DT > '&END_DATE'

7. EXPRTN_DT > '''&END_DATE'''   /*Note: Single Quotes surrounded by Single Quotes)*/

 

If need be, willing to provide error messages, but most of them were as below:

1. ERROR: Error fetching from cursor. ORACLE error is ORA-12801: error signaled in parallel query server P019
    ORA-01858: a non-numeric character was found where a numeric was expected.

2. Missing right Paranthesis.

 

Any help is greatly appreciated.

 

P.S. I was able to run the query in dBeaver with hardcoded date as '31MAR2017' and it worked fine. 

1 ACCEPTED SOLUTION

Accepted Solutions
RVP
Calcite | Level 5 RVP
Calcite | Level 5

So wasted a day and oddly found the solution on Stackoverflow. 

 

Solution:

 

Changed this: EXPRTN_DT > TO_DATE(&END_DATE,'DDMONYYYY')

 

To this: EXPRTN_DT > %BQUOTE('&QTR_END_DATE') 

 

Credit: https://stackoverflow.com/questions/9830518/proper-syntax-for-sas-macro-date-in-oracle-query

Last Answer by Chris J. 

View solution in original post

1 REPLY 1
RVP
Calcite | Level 5 RVP
Calcite | Level 5

So wasted a day and oddly found the solution on Stackoverflow. 

 

Solution:

 

Changed this: EXPRTN_DT > TO_DATE(&END_DATE,'DDMONYYYY')

 

To this: EXPRTN_DT > %BQUOTE('&QTR_END_DATE') 

 

Credit: https://stackoverflow.com/questions/9830518/proper-syntax-for-sas-macro-date-in-oracle-query

Last Answer by Chris J. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1738 views
  • 0 likes
  • 1 in conversation