Reading and Writing Data Using the SQLSTMT Package and the SQLEXEC Function

Note: The SQLSTMT package and the SQLEXEC function are not supported on the CAS server.

The SQLSTMT package and the SQLEXEC function enable DS2 programs to dynamically generate, prepare, and execute FedSQL statements to update, insert, or delete rows from a table. With an instance of the SQLSTMT package or the SQLEXEC function, the FedSQL statement allocate, prepare, execute, and free occurs at run time.

In addition, the SQLSTMT package can interrogate the result set that is produced by the executed FedSQL statement.

CAUTION

Only FedSQL statements can be used with the SQLEXEC function and the SQLSTMT package. DBMS-specific SQL cannot be used. For more information, see SAS FedSQL Language Reference.

For more information, see Using the SQLSTMT Package and the SQLEXEC Function in SAS DS2 Language Reference.

TipBy using a parameterized FedSQL query in the SQLSTMT package, you can achieve what the DATA step SET statement with KEY= does.
Last updated: August 17, 2026