BookmarkSubscribeRSS Feed
mray
Calcite | Level 5

Hello,

I am a beginner with connecting to metatables and accessing the data from there.  Usually I used to have the tables locally on my desktop.

I am confused about what is wrong in this code.  Showing the code and the error generated as well as the desired output.

Desired output (just a snippet)-

snip1.PNG

SAS Code-

proc sql;

  connect to oracle(authdomain="OracleAuth" buffsize=32767 preserve_comments path = 'roscop');

  execute (alter session set nls_date_format = 'mm/dd/yyyy') by oracle ;


   create table mray2 as

    select *

    from connection to oracle

(SELECT
  CNTCT.CNTCT_OPEN_DT,
  CNTCT.CNTCT_TYPE_DESC,
  CNTCT.CNTCT_INIATR_DESC,
  sum(decode(CNTCT.CNTCT_NEW_IND,'Y',1,0)),
  CNTCT.SRC_SYS_DESC
FROM
  CNTCT
WHERE
  CNTCT.CNTCT_OPEN_DT  BETWEEN  '01-01-2015 00:00:00'dt  AND  '21-08-2015 00:00:00'dt
GROUP BY
  CNTCT.CNTCT_OPEN_DT,
  CNTCT.CNTCT_TYPE_DESC,
  CNTCT.CNTCT_INIATR_DESC,
  CNTCT.SRC_SYS_DESC

  )


    ;

    disconnect from oracle;

QUIT;

Error MSG-

ERROR: ORACLE prepare error: ORA-00905: missing keyword. SQL statement: SELECT CNTCT.CNTCT_OPEN_DT, CNTCT.CNTCT_TYPE_DESC,

       CNTCT.CNTCT_INIATR_DESC, sum(decode(CNTCT.CNTCT_NEW_IND,'Y',1,0)), CNTCT.SRC_SYS_DESC FROM CNTCT WHERE CNTCT.CNTCT_OPEN_DT

       BETWEEN '01-01-2015 00:00:00'dt AND '21-08-2015 00:00:00'dt GROUP BY CNTCT.CNTCT_OPEN_DT, CNTCT.CNTCT_TYPE_DESC,

Any help appreciated!

Thank you.

Monika

1 REPLY 1
SASKiwi
PROC Star

You are using SQL passthru so your SQL must conform to Oracle's requirements.

'01-01-2015 00:00:00'dt is not a valid Oracle datetime string. Try removing the DT on the end - this is SAS-specific syntax. Just using a date like '01-JAN-2015' may also work.

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
  • 1043 views
  • 0 likes
  • 2 in conversation