Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using db links in a proc sql

Status
Not open for further replies.

fyr

Programmer
Jan 4, 2002
11
US
I currently use a proc sql; statement to grab data from a table in Oracle to create a data set that I later manipulate in SAS. I have a particular query that utilizes db-links, allowing me to write a select statement accessing tables in various schemas. I would like to use this select statement to write a proc sql; statement in SAS so that I have this data set. Has anyone ever managed to use db-links in SAS?

 
I am not sure if this will help, as I haven't used Oracle. You could use the ODBC engine that SAS has. (window users only) The concept is simple. You set up a windows dsn file using the ODBC manager usually found in the control panel. Using the LIBNAME statement SAS 'sees' that datasource as a SAS library. The name of your dsn file is now used in a LIBNAME statement in the following way.

LIBNAME _temp ODBC dsn="your_data_source_name";

The SAS library _temp will now be a window into that database. (This is a SAS version 8.0 and up feature.)
I hope this helps you.
 
Thank you so much! The information you provided was enough to find the appropriate Tech Doc on the sas website. I ended up doing the following:

LIBNAME ora1 oracle user=username password=password path="db-path" schema=schemaname;
LIBNAME ora2 oracle user=username password=password path="db-path" schema=schemaname2;

And wrote a proc sql statement that then used the tables in the schemas pointed by the library definitions. I didn't know this could be done, and it really helped. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top