user3862708
user3862708

Reputation: 1

Multiple databases of Teradata and SAS in UNIX

I would like to know how to query multiple databases of the same server of Teradata in SAS (unix). I can do it for one database but there are few different databases involved in my queries. The only related article was SAS connection to Teradata Database using Teradata ODBC but could not get the right answer. Could you please share syntax/snippet. Any comment is appreciated. Thanks!

Jas

Edits:

Please see the below script, I want to do something like this.

libname lib 'mylibraryPath\';

proc sql;
connect to teradata  (user="userid" password="pwaaaowrd" mode=teradata  database=DB1   database=DB2   database=DB3   tdpid="MyServer");
execute (
create volatile table lib.tab1 as 
(

Select statements and several joins of different tables from different databases (server is same)
)
WITH DATA
PRIMARY INDEX (abcd)
ON COMMIT PRESERVE ROWS;
)
By Teradata;
execute (commit work) by Teradata;
disconnect from teradata;
quit;

Upvotes: 0

Views: 1608

Answers (1)

DaBigNikoladze
DaBigNikoladze

Reputation: 661

as written by Chris in the Question you linked you could use a so called implicit pass-through defining a libname for every Teradata db you need to point to:

libname db1 teradata user=xxx1 password=yyy1 database=zzz1;
libname db2 teradata user=xxx2 password=yyy2 database=zzz2;

Then you can use these inside Data steps or SQL queries as if they were standard SAS libraries:

data join;
    merge db1.table1 db2.table2;
    by id;
run;

or

proc sql;
    select *
    from db1.table1 t1
    left join db2.table2 t2
        on t1.id=t2.id;
quit;

Upvotes: 1

Related Questions