Published on :
ETL INTERNAL_CREATION

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
The program illustrates how to configure a SAS©/ACCESS libname for Teradata with the TPT option, and how to use it with PROC APPEND and PROC SQL for fast loading. It presents different TPT options such as 'fastload', 'multistmt', and 'multiload' to optimize loading performance. The script also includes steps for creating temporary data and dropping tables for demonstration purposes.
Data Analysis

Type : INTERNAL_CREATION


The source data ('work.test') used for loading is created directly in the script via DATA STEPS. The destination is an external Teradata database, connected via a SAS/ACCESS libname.

1 Code Block
LIBNAME
Explanation :
Defines a SAS library (`mybulk`) to connect to a Teradata database using SAS/ACCESS. The `tpt=yes` option enables the Teradata Parallel Transporter for more efficient bulk data loading. The macro variables `&dbms` and `&CONNOPT` are assumed to be defined upstream for the database connection.
Copied!
1LIBNAME mybulk &dbms &CONNOPT tpt=yes;
2 Code Block
PROC DELETE
Explanation :
Deletes tables 'test1' and 'test2' from the Teradata database (`mybulk`) if they exist, ensuring a clean environment for the demonstration.
Copied!
1 
2PROC DELETE
3DATA=mybulk.test1;
4 
5RUN;
6PROC DELETE
7DATA=mybulk.test2;
8 
9RUN;
10 
3 Code Block
DATA STEP Data
Explanation :
Creates a temporary SAS dataset named 'work.test' with a single observation where variable 'x' has the value 1. This dataset serves as the source for loading operations.
Copied!
1DATA work.test;
2 x=1; OUTPUT;
3RUN;
4 Code Block
PROC APPEND
Explanation :
Appends data from the SAS dataset 'work.test' to the Teradata table 'mybulk.test1'. The `tpt=yes` option enables TPT and `fastload=yes` indicates using TPT's fastload mode, which is generally more performant for large data volumes.
Copied!
1 
2PROC APPEND base=mybulk.test1 (tpt=yes fastload=yes)
3 
4DATA=work.test;
5RUN;
6 
5 Code Block
PROC DELETE
Explanation :
Deletes table 'test1' from Teradata before recreating it with PROC SQL.
Copied!
1PROC DELETE DATA=mybulk.test1; RUN;
6 Code Block
PROC SQL
Explanation :
Creates a new Teradata table 'mybulk.test2' from the SAS dataset 'work.test' using PROC SQL. The `tpt=yes` and `fastload=yes` options are applied at creation time for efficient data loading.
Copied!
1PROC SQL;
2 create TABLE mybulk.test2 (tpt=yes fastload=yes) as
3 select * from work.test;
4QUIT;
7 Code Block
DATA STEP Data
Explanation :
Recreates the temporary SAS dataset 'work.test' with five observations (x from 1 to 5). This updated dataset will be used to demonstrate other TPT options.
Copied!
1DATA work.test;
2 x=1; OUTPUT;
3 x=2; OUTPUT;
4 x=3; OUTPUT;
5 x=4; OUTPUT;
6 x=5; OUTPUT;
7RUN;
8 Code Block
PROC SQL
Explanation :
Creates the Teradata table 'mybulk.test1' from 'work.test' using PROC SQL with TPT options `tpt=yes` and `fastload=yes` for fast loading.
Copied!
1PROC SQL;
2 create TABLE mybulk.test1 (tpt=yes fastload=yes)
3 as select * from work.test;
4QUIT;
9 Code Block
PROC DELETE
Explanation :
Deletes table 'test1' from Teradata before recreating it with the 'multistmt' option.
Copied!
1PROC DELETE DATA=mybulk.test1; RUN;
10 Code Block
PROC SQL
Explanation :
Creates the Teradata table 'mybulk.test1' with the TPT option `multistmt=yes`, which can improve performance by combining multiple SQL statements into a single TPT transaction.
Copied!
1PROC SQL;
2 create TABLE mybulk.test1 (tpt=yes multistmt=yes)
3 as select * from work.test;
4QUIT;
11 Code Block
PROC DELETE
Explanation :
Deletes table 'test1' from Teradata before recreating it with the 'multiload' option.
Copied!
1PROC DELETE DATA=mybulk.test1; RUN;
12 Code Block
PROC SQL
Explanation :
Creates the Teradata table 'mybulk.test1' with the TPT option `multiload=yes`, another TPT optimization technique for parallel data loading.
Copied!
1PROC SQL;
2 create TABLE mybulk.test1 (tpt=yes multiload=yes)
3 as select * from work.test;
4QUIT;
13 Code Block
PROC DELETE
Explanation :
Performs a final cleanup by deleting tables 'test1' and 'test2' created in Teradata during the demonstration.
Copied!
1 
2PROC DELETE
3DATA=mybulk.test1;
4 
5RUN;
6PROC DELETE
7DATA=mybulk.test2;
8 
9RUN;
10 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : NAME: tpt.sas TITLE: Sample Programs PRODUCT: SAS/ACCESS to Teradata SYSTEM: z/OS, UNIX, WINDOWS REF: SAS/ACCESS 9 for Relational Databases: Reference