Previous Page | Next Page

Language Reference

CLOSE Statement

CLOSE <SAS-data-set> ;

The CLOSE statement is used to close one or more SAS data sets opened with the USE, EDIT, or CREATE statement.

The optional argument specifies the name of one or more SAS data sets. The data sets can be specified with a one-level name (for example, A) or a two-level name (for example, Sasuser.A). For more information about specifying SAS data sets, refer to Chapter 7, Working with SAS Data Sets.

You can use the SHOW DATASETS statement to find the names of open data sets.

SAS/IML software automatically closes all open data sets when a QUIT statement is executed.

The following statements provide examples of using the CLOSE statement:

use Sashelp.Class;
read all var _NUM_ into x[colname=VarName];

corr = corr(x);
create ClassCorr from corr[rowname=VarName colname=VarName];
append from corr[rowname=VarName];

show datasets;
close Sashelp.Class ClassCorr;

Figure 23.55 Open Data Sets
LIBNAME  MEMNAME                          OPEN MODE   STATUS                    
-------- -------------------------------- ---------   --------                  
SASHELP  CLASS                            Input                                 
WORK     CLASSCORR                        Update      Current Input/Output      
                                                                                

It is good programming practice to close data sets when you are finished using them.

Previous Page | Next Page | Top of Page