13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface to Teradata 4 Using the <strong>SAS</strong>_PUT( ) Function in the Teradata EDW 829A large value, VARCHAR(n), is always returned because one function prototypeaccesses all <strong>for</strong>mats. Use the CAST expression to reduce the width of the returnedcolumn to be a character width that is reasonable <strong>for</strong> the <strong>for</strong>mat that is being used.The return text cannot contain a binary zero value (hexadecimal 00) becausethe <strong>SAS</strong>_PUT( ) function always returns a VARCHAR(n) data type and a TeradataVARCHAR(n) is defined to be a null-terminated string.The SELECT DISTINCT clause executes inside Teradata, and the processing isdistributed across all available data nodes. Teradata <strong>for</strong>mats the price values with the$DOLLAR8.2 <strong>for</strong>mat and processes the SELECT DISTINCT clause using the <strong>for</strong>mattedvalues.Explicit Use of the <strong>SAS</strong>_PUT( ) FunctionIf you use explicit pass-through (direct connection to Teradata), you can use the<strong>SAS</strong>_PUT( ) function call in your SQL program.This example shows the same query from “Implicit Use of the <strong>SAS</strong>_PUT( ) Function”on page 827 and explicitly uses the <strong>SAS</strong>_PUT( ) function call.proc sql noerrorstop;title1 ’Test <strong>SAS</strong>_PUT using Explicit Passthru;connect to teradata (user=sas password=XXX database=sas server=sl96208);select * from connection to teradata(select distinct cast(sas_put("PRICE",’DOLLAR8.2’) as char(8)) as"PRICE_C" from mailorderdemo);disconnect from teradata;quit;The following lines are written to the <strong>SAS</strong> log.proc sql noerrorstop;title1 ’Test <strong>SAS</strong>_PUT using Explicit Passthru ’;connect to teradata (user=sas password=XXX database=sas server=sl96208);select * from connection to teradata(select distinct cast(sas_put("PRICE",’DOLLAR8.2’) as char(8)) as"PRICE_C" from mailorderdemo);Test <strong>SAS</strong>_PUT using Explicit Passthru 1013:42 Thursday, September 25, 2008PRICE_C_______$8.00$10.00$12.00$13.59$13.99$14.00$27.98$48.99$54.00disconnect from teradata;quit;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!