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.

816 Reducing Workload on Teradata by Sampling 4 Chapter 28This example removes the PROC SORT statement shown in the previous example. Itinstead uses a BY clause with a VAR clause with PROC PRINT. The BY clause returnsTeradata rows ordered by the INCOME column.libname sortprt teradata user=testuser password=testpass;proc print data=sortprt.salaries;var income;by income;Reducing Workload on Teradata by SamplingThe OBS= option triggers <strong>SAS</strong>/<strong>ACCESS</strong> to add a SAMPLE clause to generated SQL.In this example, 10 rows are printed from dbc.ChildrenX:Libname tra teradata user=sasdxs pass=******Proc print data=tra.ChildrenX (obs=10);run;database=dbc;The SQL passed to Teradata is:SELECT "Child","Parent" FROM "ChildrenX" SAMPLE 10Especially against large Teradata tables, small values <strong>for</strong> OBS= reduce workload andspool space consumption on Teradata and your queries complete much sooner. See theSAMPLE clause in your Teradata documentation <strong>for</strong> further in<strong>for</strong>mation.Deploying and Using <strong>SAS</strong> Formats in TeradataUsing <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, including in-database procedures, frequently use both user-defined<strong>for</strong>mats and <strong>for</strong>mats that <strong>SAS</strong> supplies. Although they are referenced in numerousways, using the PUT function in the 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:

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

Saved successfully!

Ooh no, something went wrong!