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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

634 Deploying and Using <strong>SAS</strong> Formats in Netezza 4 Chapter 22Deploying and Using <strong>SAS</strong> Formats in NetezzaUsing <strong>SAS</strong> Formats<strong>SAS</strong> <strong>for</strong>mats are basically mapping functions that change an element of data fromone <strong>for</strong>mat to another. For example, some <strong>SAS</strong> <strong>for</strong>mats change numeric values tovarious currency <strong>for</strong>mats or date-and-time <strong>for</strong>mats.<strong>SAS</strong> supplies many <strong>for</strong>mats. You can also use the <strong>SAS</strong> FORMAT procedure to definecustom <strong>for</strong>mats that replace raw data values with <strong>for</strong>matted character values. Forexample, this PROC FORMAT code creates a custom <strong>for</strong>mat called $REGION thatmaps ZIP codes to geographic regions.proc <strong>for</strong>mat;value $region’02129’, ’03755’, ’10005’ = ’Northeast’’27513’, ’27511’, ’27705’ = ’Southeast’’92173’, ’97214’, ’94105’ = ’Pacific’;run;<strong>SAS</strong> programs frequently use both user-defined <strong>for</strong>mats and <strong>for</strong>mats that <strong>SAS</strong>supplies. Although they are referenced in numerous ways, using the PUT function inthe SQL procedure is of particular interest <strong>for</strong> <strong>SAS</strong> In-Database processing.The PUT function takes a <strong>for</strong>mat reference and a data item as input and returns a<strong>for</strong>matted value. This SQL procedure query uses the PUT function to summarize salesby region from a table of all customers:select put(zipcode,$region.) as region,sum(sales) as sum_sales from sales.customersgroup by region;The <strong>SAS</strong> SQL processor knows how to process the PUT function. Currently,<strong>SAS</strong>/<strong>ACCESS</strong> Interface to Netezza returns all rows of un<strong>for</strong>matted data in theSALES.CUSTOMERS table in the Netezza database to the <strong>SAS</strong> System <strong>for</strong> processing.The <strong>SAS</strong> In-Database technology deploys, or publishes, the PUT functionimplementation to Netezza as a new function named <strong>SAS</strong>_PUT( ). Similar to any otherprogramming language function, the <strong>SAS</strong>_PUT( ) function can take one or more inputparameters and return an output value.The <strong>SAS</strong>_PUT( ) function supports use of <strong>SAS</strong> <strong>for</strong>mats. You can specify the<strong>SAS</strong>_PUT( ) function in SQL queries that <strong>SAS</strong> submits to Netezza in one of two ways:3 implicitly by enabling <strong>SAS</strong> to automatically map PUT function calls to <strong>SAS</strong>_PUT( )function calls3 explicitly by using the <strong>SAS</strong>_PUT( ) function directly in your <strong>SAS</strong> programIf you used the <strong>SAS</strong>_PUT( ) function in the previous example, Netezza <strong>for</strong>mats theZIP code values with the $REGION <strong>for</strong>mat and processes the GROUP BY clause usingthe <strong>for</strong>matted values.By publishing the PUT function implementation to Netezza as the <strong>SAS</strong>_PUT( )function, you can realize these advantages:3 You can process the entire SQL query inside the database, which minimizes datatransfer (I/O).3 The <strong>SAS</strong> <strong>for</strong>mat processing leverages the scalable architecture of the DBMS.3 The results are grouped by the <strong>for</strong>matted data and are extracted from the Netezzadata warehouse.

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

Saved successfully!

Ooh no, something went wrong!