The FREQ Procedure
In-Database Computation
The FREQ procedure can use in-database computation to construct frequency and crosstabulation tables when the DATA= input data set is stored as a table in a supported database management system (DBMS). When large data sets are stored in an external database, the transfer of the data sets to computers that run SAS can be affected by performance, security, and resource management issues. SAS in-database processing can greatly reduce data transfer by having the database perform the initial data aggregation. For more information about in-database processing, see SAS/ACCESS for Relational Databases: Reference.
In-database computation for PROC FREQ supports the following database management systems:
Amazon Redshift
DB2
Google BigQuery
Greenplum
Hadoop
Impala
Microsoft SQL Server
MySQL
Netezza
Oracle
PostgreSQL
SAP HANA
Snowflake
Spark
Teradata
Vertica
Yellowbrick
PROC FREQ performs in-database computation by using SQL implicit pass-through. The procedure generates SQL queries that are based on the tables that you request in the TABLES statement. The database executes these SQL queries to construct initial summary tables, which are then transmitted to PROC FREQ. The procedure uses this summary information to perform the remaining analyses and tasks in the usual way (out of the database). Instead of transferring the entire data set over the network between the database and SAS software, in-database computation transfers only the summary tables. This can substantially reduce processing time when the dimensions of the summary tables (in terms of rows and columns) are much smaller than the dimensions of the entire database table (in terms of individual observations). In addition, in-database summarization uses efficient parallel processing, which can also provide performance advantages.
In-database computation is controlled by the SQLGENERATION option, which you can specify in either a LIBNAME statement or an OPTIONS statement. For information about the SQLGENERATION option and other options that affect in-database computation, see the section "In-Database Procedures" in SAS/ACCESS for Relational Databases: Reference. By default, PROC FREQ uses in-database computation when possible. PROC FREQ has no procedure options that control in-database computation.
PROC FREQ uses formatted values to group observations into the levels of frequency and crosstabulation tables. For more information, see the section Grouping with Formats. If formats are available in the database, in-database summarization uses the formats. If formats are not available in the database, the in-database summarization uses the raw data values, and PROC FREQ performs the final, formatted classification (out of the database). For more information, see the section "Deploying and Using SAS Formats in Teradata" in SAS/ACCESS for Relational Databases: Reference.
The order of observations is not inherently defined for DBMS tables. The following options relate to the order of observations and therefore should not be specified for PROC FREQ in-database computation:
If you specify the FIRSTOBS= or OBS= data set option, PROC FREQ does not perform in-database computation.
If you specify the NOTSORTED option in the BY statement, PROC FREQ in-database computation ignores it and uses the default ASCENDING order for BY variables.
If you specify the ORDER=DATA option for input data in a DBMS table, PROC FREQ computation might produce different results for separate runs of the same analysis. In addition to determining the order of variable levels in crosstabulation table displays, the ORDER= option can also affect the values of many of the test statistics and measures that PROC FREQ computes.