Quantcast
Channel: ListenData
Viewing all articles
Browse latest Browse all 425

Connect to Teradata using SAS

$
0
0
This tutorial explains how to connect to teradata using SAS.

Write queries with Teradata SQL syntax

In simple words, we are creating Teradata SQL statements and then pass them to the Teradata server for execution. Only Teradata SQL functions would work within "connection to teradata" code. For example, INPUT PUT functions would not work. Instead, cast function would be used for changing variable type.
proc sql;
   connect to teradata (user="youruserid" password="yourpassword" server="servername" mode=teradata);
   create table temp as
   select * from connection to teradata (
      select a.ID
           , a.Product
           , b.Income
      from tdbase.customer a
      join tdbase.income b
      on a.ID=b.ID
      );
  disconnect from teradata;
quit;
Note :
  1. user = provide username of your teradata account.
  2. password =  provide password of your teradata account.
  3. server = provide server name

Creating Teradata Volatile Tables
proc sql;
 connect to teradata (user="youruserid" password="yourpassword" mode=teradata  server="servername" connection=global);
 execute(
 create volatile table temp as (
 select id
 , region
 , sector
 , income
 from ls_policy_inter
 group by 1,2
 )
 with data primary index (id)
 on commit preserve rows
 ) by teradata;
quit;

Important Teradata Functions inside SAS

The following code would work inside the EXECUTE BY function.
qualify rank() over ( partition by region order by income desc ) = 1
  1. QUALIFY - similar to HAVING clause
  2. RANK()- rank values
  3. OVER - define the criteria
  4. PARTITION - similar to GROUP BY
  5. ROW_NUMBER - row number (similar to _N_ in data step)

Viewing all articles
Browse latest Browse all 425

Trending Articles