This tutorial explains how to connect to teradata using SAS.
Important Teradata Functions inside 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.
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;Note :
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;
- user = provide username of your teradata account.
- password = provide password of your teradata account.
- 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
- QUALIFY - similar to HAVING clause
- RANK()- rank values
- OVER - define the criteria
- PARTITION - similar to GROUP BY
- ROW_NUMBER - row number (similar to _N_ in data step)