DISCONNECT Statement

Terminates the connection to the DBMS
Valid in: PROC SQL steps (when accessing DBMS data using SAS/ACCESS software)

Syntax

DISCONNECT FROM dbms-name | alias

Required Arguments

dbms-name
specifies the database management system from which you want to disconnect. You must either specify the DBMS name for your SAS/ACCESS interface or use an alias in the DISCONNECT statement.
Note: If you used the CONNECT statement to connect to the DBMS, the DBMS name or alias in the DISCONNECT statement must match what you specified in the CONNECT statement.
alias
specifies an alias that was defined in the CONNECT statement.

Details

The DISCONNECT statement ends the connection with the DBMS. If you do not include the DISCONNECT statement, SAS performs an implicit DISCONNECT when PROC SQL terminates. The SQL procedure continues to execute until you submit a QUIT statement, another SAS procedure, or a DATA step.
Any return code or message that is generated by the DBMS is available in the macro variables SQLXRC and SQLXMSG after the statement executes. See Macro Variables for Relational Databases for more information about these macro variables.

Example

To exit the SQL pass-through facility, use the facilities DISCONNECT statement and then QUIT the PROC SQL statement. This example disconnects the user from a DB2 database with the alias DBCON1 and terminates the SQL procedure.
proc sql;
connect to db2 as dbcon1 (ssid=db2a);
…more SAS statements…
disconnect from dbcon1;
quit;