SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

Via this code I connect to tera table and create a sas table called VBM376 (must use tera/sql language here)

proc sql;  
connect to teradata (server=dwprod  schema=DWP_vall authdomain=TeraDataAuth mode=teradata);
create table VBM376  as 
select * from connection to teradata
(
SELECT   top 5 *
from VBM376_INTERNAL_ORGANIZATION
);
disconnect from teradata;
quit ;

I saw in internet the option to run following code.

I dont see that any sas data set was created here.

My question - what exactly this code is doing? 

Is it creating a tera table in tera?

Then can I use this tera table in sas ?


proc sql;
connect to teradata (server=dwprod  schema=DWP_vall authdomain=TeraDataAuth mode=teradata);
 execute(
 create volatile table VBM376_b as (
SELECT   top 5 *
from VBM376_INTERNAL_ORGANIZATION
 )
 with data primary index (Team_IP)
 on commit preserve rows
 ) by teradata;
quit;
5 REPLIES 5
LinusH
Tourmaline | Level 20
You are right.
When you are using EXECUTE ( ) BY; "nothing" happens in SAS. In this example a temporary table is created in TD.
If you modify the syntax a bit, you can use it in SAS. See this thread for an example:
https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-a-Volatile-Table-from-Tereadata-to-SAS-EG-S...
Data never sleeps
Ronein
Meteorite | Level 14

THANK YOU

tell please what is the benefit of creating a vilotate table in tera via sas?

 

Is it possible then to merge this tera table with other sas daat set?

Also, I run this code and I dont understand what happens

 

libname tdwork teradata 
AUTHDOMAIN=TeraDataAuth 
mode=teradata  
server=dwprod
connection=global 
dbmstemp=yes
;
PROC SQL NOERRORSTOP;
CONNECT USING TDWORK as TERADATA;
EXECUTE BY TERADATA 
( create volatile table VBM376_b as
  (
SELECT   top 5 *
from VBM376_INTERNAL_ORGANIZATION
  )
with data primary index(Team_IP) On Commit Preserve Rows 
);
 
Patrick
Opal | Level 21

@Ronein Just copy/paste your code into Copilot and you'll get already a lot of explanation. If after this something still remains unclear ask a more targeted question - eventually on a Teradata forum if it's about the Teradata SQL portion.

 

In SAS you can have session scope tables in WORK. They all get dropped automatically when your SAS session ends. In Teradata volatile tables are also session specific and get dropped automatically once the Teradata session ends. And both in SAS and Teradata these session specific tables are only accessible within the session so you also don't have to worry about security. 

 

What's important is connection=global because it enables that consecutive steps like multiple Proc SQLs can use the same connection/Teradata session and though can all access to the volatile table once created.

 

The most common use case for temporary/volatile DB tables is for loading data. You load your SAS data into a temporary DB table and then do all the inserts and updates in-database. And once your session ends there is no need to clean-up (same as with SAS tables in WORK).  ...you just need always to read-up how temporary tables really work for the DB you're using. In Oracle for example temporary tables are a bit more permanent. The table definition is permanent, the data attached to the table definition can have session or transaction scope. 

Ronein
Meteorite | Level 14

So If I open Tera then I can use this violtate table from tera?

What is the using of such code?

I am trying to understand how can I use it for my needs?

Please note that I have both SAS dat sets and tera tables that I need to work with (merge,set, and so on).

My target is to work VIA SAS platform and using sas data sets and tera tables

LinusH
Tourmaline | Level 20
Check with a Teradata DBA to guide you on how to use TD tables.
Not sure what your use case is - what is the purpose of creating volatile tables from SAS, and then access from TD?
Data never sleeps

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1462 views
  • 0 likes
  • 3 in conversation