BookmarkSubscribeRSS Feed
Amber_Nicole94
Obsidian | Level 7

Can someone help write the code to connect SAS EG to Oracle database?

 

This is what i have so far:

PROC SQL;
	CONNECT TO ORACLE AS DBCON
		(USER=XXXX PASSWORD=XXXX PATH='EDWP');
	select *       
   	from connection to oracle
(select*from CUSTOMERS);
    disconnect from oracle; 
quit;

However, I recieve an error once I get to "customers". I do not know if cuctomers is even what I should be putting there. From my IT department, I recieved a list of oracle tables and IDWE_OWN.CUSTOMERS was one of the tables listed.

 

 

Using SAS EG 5.1

7 REPLIES 7
kiranv_
Rhodochrosite | Level 12

Everything looks right. try change it to IDWE_OWN.CUSTOMERS instead of customers

Amber_Nicole94
Obsidian | Level 7

I have tried what you suggested and am still recieving the following error:

 

ERROR: ORACLE connection error: ORA-12162: TNS:net service name is incorrectly specified.

 

kiranv_
Rhodochrosite | Level 12

I think what you might used and I suggested is libname assigned for a particular schema in oracle. Please ask the IT people, what is the name of schema.

Amber_Nicole94
Obsidian | Level 7

How would i create a libname? Sorry, I am fairly new to SAS.

 

The name of the schema is IDWE, the environment is PROD and the database name is EDWP.

Sven111
Pyrite | Level 9

I generally connect with a LIBNAME statement and then use that in PROC SQL.  This way I can use one connection for both implicit and explicit pass-through SQL. For you it would probably look something like this:

LIBNAME OracSAS ORACLE USER=&UserNm PASS=&PassWd PATH='EDWP' SCHEMA=IDWE CONNECTION=GLOBAL;

PROC SQL;
    CONNECT USING OracSAS AS OracDB;
    /* CODE */
    DISCONNECT FROM OracDB;
QUIT;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

From memory (quite a while back) TNSNames.txt is a file on your computer with connection information.  It sounds like this file is missing, or has incorrect information in it.  Contact your IT and get them to update it.

Tom
Super User Tom
Super User

You should get the IT department to configure the TNS names file properly for you.

If that is not possible you can tell SAS the information that it would normally lookup using the tnsname directly.

See this guide.

https://communities.sas.com/t5/SAS-Communities-Library/A-quick-guide-to-connecting-to-Oracle-from-SA...

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 7 replies
  • 11554 views
  • 0 likes
  • 5 in conversation