how to reference a lib table while inside a teradata connection?
Thanks for your reply!
I am using this method to connect Teradata:
"PROC SQL;
CONNECT TO TERADATA(SERVER='xxxx' SCHEMA='VWDW' USER="xxxx" PASSWORD="xxxx" MODE=TERADATA);"
I want to see some table in my work/lib in SAS and make filters using my own table inside the SAS.
Is it possible?
@arcastro wrote:
Thanks for your reply!
I am using this method to connect Teradata:
"PROC SQL;
CONNECT TO TERADATA(SERVER='xxxx' SCHEMA='VWDW' USER="xxxx" PASSWORD="xxxx" MODE=TERADATA);"
I want to see some table in my work/lib in SAS and make filters using my own table inside the SAS.
Is it possible?
It is still hard to tell what you want to do. You can clarify by describing a simple example. Show what tables you have, clearly indicating which are in Teradata and which are not, and then describe the query you need to execute using those tables.
Note that you should be able to create volatile tables inside your Teradata database that will live for the duration of your Teradata session. Similar to WORK datasets in SAS.
@arcastro wrote:
Thanks for your reply!
I am using this method to connect Teradata:
"PROC SQL;
CONNECT TO TERADATA(SERVER='xxxx' SCHEMA='VWDW' USER="xxxx" PASSWORD="xxxx" MODE=TERADATA);"
I want to see some table in my work/lib in SAS and make filters using my own table inside the SAS.
Is it possible?
Most likely yes, but exactly how depends on the query.
Thanks again!
You can see a simple example below.
I am connecting in a Teradata Server, and I want to make a join with a table that is outside of this connection, like a Lib or Work. I just wanna make a filter using auxiliar table in my teradata query. This auxlliar tabela could be temporarily, no problem.
LIBNAME R_PNL '/sasusers/workgroup/PNL';
PROC SQL;
CONNECT TO TERADATA(SERVER='xxx' SCHEMA='VWDW' USER="xxxxx" PASSWORD="xxxx" MODE=TERADATA);
CREATE TABLE Test AS
SELECT * FROM CONNECTION TO TERADATA
(Select * FROM VWDW.VDW_TERA AS X
INNER JOIN R_PNL.COSTUMERS AS Y ON Y.ID = X.ID
);
DISCONNECT FROM TERADATA;
QUIT;
LIBNAME R_PNL '/sasusers/workgroup/PNL';
proc sql noprint;
select distinct iD into :id_list separated by ", "
from r_pnl.costumers;
quit;
PROC SQL;
CONNECT TO TERADATA(SERVER='xxx' SCHEMA='VWDW' USER="xxxxx" PASSWORD="xxxx" MODE=TERADATA);
CREATE TABLE Test AS
SELECT * FROM CONNECTION TO TERADATA
(Select * FROM VWDW.VDW_TERA AS X
INNER JOIN R_PNL.COSTUMERS AS Y ON Y.ID in (&id_list)
);
DISCONNECT FROM TERADATA;
QUIT;
Here's one way if the list of ID's is manageable (macro variables have a limit of 64k characters)
If it gets too big you can create a dynamic macro to generate the list instead.
The auxiliar table has more than 65534 characters.
ERROR: The length of the value of the macro variable ID_LIST (65540) exceeds the maximum length (65534). The value has been truncated to 65534 characters.
How would it be "dynamic macro"?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.