O'Reilly logo

SAS 9.4 SQL Procedure User's Guide, Fourth Edition, 4th Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For more information about using the In-database format publishing macro and the
SQLMAPPUTTO system option, see SAS/ACCESS for Relational Databases: Reference.
Replacing References to the DATE, TIME, DATETIME, and TODAY
Functions
When the PROC SQL CONSTDATETIME option or the SQLCONSTDATETIME
system option is set, PROC SQL evaluates the DATE, TIME, DATETIME, and TODAY
functions in a query once, and uses those values throughout the query. Computing these
values once ensures consistent results when the functions are used multiple times in a
query, or when the query executes the functions close to a date or time boundary. When
referencing database tables, performance is enhanced because it allows more of the
query to be passed down to the database.
For more information, see the “SQLCONSTDATETIME System Option” on page 373
or the CONSTDATETIME option in the Base SAS Procedures Guide.
Note: If you specify both the PROC SQL REDUCEPUT option or the
SQLREDUCEPUT= system option and the PROC SQL CONSTDATETIME option
or the SQLCONSTDATETIME system option, PROC SQL replaces the DATE,
TIME, DATETIME, and TODAY functions with their respective values in order to
determine the PUT function value before the query executes.
Disabling the Remerging of Data When Using Summary Functions
When you use a summary function in a SELECT clause or a HAVING clause, PROC
SQL might remerge the data. Remerging the data involves two passes through the data.
If you set the PROC SQL NOREMERGE option or the NOSQLREMERGE system
option, PROC SQL will not process the remerging of data. When referencing database
tables, performance is enhanced because it enables more of the query to be passed down
to the database.
For more information, see the PROC SQL statement REMERGE option in the Base SAS
Procedures Guide and the SQLREMERGE system option in Appendix 1, “SQL Macro
Variables and System Options,” on page 373.
Using Column Aliases
Overview of Column Aliases
A column alias is a temporary, alternate name for a column. Aliases are specified in the
SELECT clause to name or rename columns so that the result table is clearer or easier to
read. Aliases are often used to name a column that is the result of an arithmetic
expression or summary function. An alias is one word only. If you need a longer column
name, then use the LABEL= column-modifier, as described in “column-modifier” on
page 321. The keyword AS is required with a column alias to distinguish the column
alias from column names in the SELECT clause.
Column aliases are optional, and each column name in the SELECT clause can have an
alias. After you assign an alias to a column, you can use the alias to refer to that column
in other clauses.
If you use a column alias when creating a PROC SQL view, then the alias becomes the
permanent name of the column for each execution of the view.
146 Chapter 5 Programming with the SQL Procedure

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required