Thursday, April 14, 2011

PROC SQL V.S. DATA STEP

BENEFITS/ADVANTAGES

The following list of benefits is not intended to be complete as much as a more general comment on issues of which the beginning SAS programmer should be aware. The lists are in no particular priority order.

PROC SQL
♦ PROC SQL provides the combined functionality of the DATA step and several base SAS procedures.
♦ Less complex and lengthy, but not as legible, code can be written in PROC SQL.
♦ PROC SQL code may execute faster for smaller tables.
♦ PROC SQL code is more portable for non-SAS programmers and non-SAS applications.
♦ PROC SQL processing does not require explicit code to presort tables.
♦ PROC SQL processing does not require common variable names to join on, although same type and length are required.
♦ By default, a PROC SQL SELECT statement prints the resultant query; use the NOPRINT option to suppress this feature.
♦ Knowledge of relational data theory opens the power of SQL for many additional tasks.
♦ PROC SQL processing forces attention to resultant data set structures, as SQL is unforgiving of "errors of design".
♦ Efficiencies within specific RDBMS are available with Pass-thru code for the performance of joins.
♦ Use of aliases for shorthand code may make some coding tasks easier.

NON-SQL BASE SAS
♦ DATA step set operators can handle more data sets at a time than PROC SQL outer joins.
♦ Non-SQL techniques can open files for read and write at the same time.
♦ Customized DATA step report writing techniques (DATA _NULL_) are more versatile than using PROC SQL SELECT clauses.
♦ The straightforward access to RDBMS tables as if they were SAS data sets negates the need to learn SQL constructs.
♦ Input of non-RDBMS external sources is easier.

No comments: