still_learning
still_learning

Reputation: 806

How to move a table from SAS to Teradata SQL Assistant?

I would like to ask you how to move a table from SAS to TeradataSQL Assistant.

What I have done in SAS is to define a libname, then create the table that I want to move in Teradata.

libname NAME "/path"

proc sql;
create table WORK.EXAMPLE as(
select *
from DATASET
);
quit;

However, I do not know if I need to connect SAS to Teradata in this way:

libname NAME teradata USER=tduser PASSWORD=tdpasswd SERVER=TDServ ; 

proc sql;
   connect to teradata (
tdpid=“” user=“” password=“”);
create table WORK.EXAMPLE as 
select * from connection to teradata
(select * from DATASET
); quit;

My questions are:

  1. in the second libname, where should I consider the path?
  2. which one of the code above should I consider and why?
  3. how can I 'call' this table in Teradata? I tried with SELECT * FROM WORK.EXAMPLE, but it does not exist.

Thank you for your help.

Upvotes: 0

Views: 2826

Answers (1)

Tom
Tom

Reputation: 51611

You can either connect to Terdata using the LIBNAME statement

libname mylib TERADATA .... ;

or the CONNECT statement in PROC SQL.

proc sql;
  connect to teradata .... ;

In fact you can even use the libref created in a previously created LIBNAME statement in your connect statement.

libname mylib TERADATA .... ;
proc sql;
  connect using mylib ;

Generally I find it easiest to use PROC APPEND to copy data into Teradata.

libname td TERADATA ... ;
libname mysas 'path to where my SAS datasets live';
proc append base=td.target_table data=mysas.source_table force;
run;

If the target table doesn't exist then SAS will create it. (In which case take care as you might not want the default variable types or the primary index that will get created that way.).

Upvotes: 1

Related Questions