Interfaces with the SQL Procedure

Using PROC SQL

Structured Query Language (SQL) is a standardized, widely used language for retrieving and updating data in databases and relational tables. SAS software's SQL processor enables you to do the following:
  • create tables and views
  • retrieve data stored in tables
  • retrieve data stored in SQL and SAS/ACCESS views
  • add or modify values in tables
  • add or modify values in SQL and SAS/ACCESS views

INTO Clause

SQL provides the INTO clause in the SELECT statement for creating SAS macro variables. You can create multiple macro variables with a single INTO clause. The INTO clause follows the same scoping rules as the %LET statement. See Macro Variables for a summary of how macro variables are created. For further details and examples relating to the INTO clause, see INTO Clause.

Controlling Job Execution

PROC SQL also provides macro tools to do the following:
  • stop execution of a job if an error occurs
  • execute programs conditionally based on data values
The following table provides information about macro variables created by SQL that affect job execution.
Macro Variables that Affect Job Execution
Macro Variable
Description
SQLEXITCODE
Contains the highest return code that occurred from some types of SQL insert failures. This return code is written to the SYSERR macro variable when PROC SQL terminates.
SQLOBS
Contains the number of rows or observations produced by a SELECT statement.
SQLOOPS
Contains the number of iterations that the inner loop of PROC SQL processes.
SQLRC
Contains the return code from an SQL statement. For return codes, see SAS SQL documentation.
SQLXMSG
Contains descriptive information and the DBMS-specific return code for the error that is returned by the pass-through facility.
SQLXRC
contains the DBMS-specific return code that is returned by the pass-through facility.