Loading data from SAS to Teradata

Reply
Occasional Contributor
Posts: 10

Loading data from SAS to Teradata

Hello everyone!

 

Let me explain you what is my little problem. I have a SAS data set with 3 columns with Numerical format (Numeric Length 8), and I would like to insert them into a Teradata table with 3 columns with the next formats: Decimal(11,3), Integer, Decimal(11,3). Nonetheless I receive a ROLLBACK error.

 

NOTE: I have enough permissions in the teradata library and I have a good conectivity.

 

The SAS code I am using is the following:

 

proc sql;

insert into tdt.table_1

select C_1 format=BEST11.3,

          C_2 format=BEST11,

          C_3 format=BEST11.3

from lib.table_2;

quit;

 

Please, can anybody explain me how to change formats in order to move data from SAS into Teradata?

 

Note: I have been reading the SAS Support link for Teradata formats, but I couldn't achieve the solution. 

http://support.sas.com/documentation/cdl/en/acreldb/69039/HTML/default/viewer.htm#n0v7nh4ylrihtin1te...

 

Thanks in advanced!

Super User
Posts: 6,941

Re: Loading data from SAS to Teradata

A number is a number is a number in SAS, meaning it is always stored as a 64 bit real number.

The formats have no effect on storage.

I guess you are better off creating a new table from SAS in Teradata and handling the insert from that table in Teradata, using explicit pass-through.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 6,941

Re: Loading data from SAS to Teradata

PS my preferred method for transfers back to the production database is to create a text file (usually fixed-width columns) and let the DBA people make the import.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 9,681

Re: Loading data from SAS to Teradata

Those formats are belong to Teradata. So you need create a table with these format
at Teradata side and load SAS dataset into Teradata ,then use INSERT by Pass-through
OR just try:
proc append base=x data=have;run;


Super User
Posts: 5,257

Re: Loading data from SAS to Teradata

The formats specified in an insert statement should have no affect to the actual data flow. So you need to make sure that your actual data values in SAS matches the expected data type in Teradata. You may need to to truncate/round to create integers as an example.

You can specify formats in SAS to control data types and length in Teradata, but only during table creation. And again, it does not affect the physical data format comming from SAS.

Data never sleeps
Occasional Contributor
Posts: 10

Re: Loading data from SAS to Teradata

I know what you mean.

 

The point is that the table's skeleton is already created on Teradata, so I cannot change the formats in it. That's why I need to know how to convert the sas formats into others to move them to Teradata tables.

Super User
Posts: 6,941

Re: Loading data from SAS to Teradata

Look what SAS types are created if you import the table into sas:

data table_1;
set tdt.table_1 (obs=1);
run;

This might give you a clue how your SAS data should be structured.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,257

Re: Loading data from SAS to Teradata

As said, you need to use SAS function to truncate/round your values, so they match the Teradata data types/precision.

Take a look at ROUND, CEIL, FLOOR...

Data never sleeps
Super User
Posts: 9,681

Re: Loading data from SAS to Teradata

Could you try DBTYPE options ?

data teradata.temp(dbtype=(a='Decimal(11,3)' b='char(20)'));
 set sas.have;
run;


Occasional Contributor
Posts: 10

Re: Loading data from SAS to Teradata

Hello everyone!

 

Finally, with some of your advices, finally I solved the problem. Here it goes the solution:

 

I defined the library with a libname statement using the following options:

 

liname tera teradata user=xxx passwrod=xxx server=xxxx schema=xxxx sql_options=all mode=teradata;

 

The, in the insert-into sql sentences i used the option (fastload=yes), as the following example:

 

proc sql;

insert into tera.table_1 (fastload=yes)

select * from lib.table2;

quit;

 

Once again, thank you so much for your advices and I hope that my solution will help you someday.

Ask a Question
Discussion stats
  • 9 replies
  • 531 views
  • 0 likes
  • 4 in conversation