The CLOSEFILE statement is used to close files opened by the INFILE or FILE statement.
The statement arguments specify the name of one or more file specifications. You can specify names (for defined filenames), literals, or expressions in parentheses (for pathnames). Each file specification should be the same as when the file was opened.
To find out what files are open, use the SHOW FILES statement. For further information, see Chapter 8. See also the description of the SAVE statement .
SAS/IML software automatically closes all files when a QUIT statement is executed.
The following example opens and closes an external file named MyData.txt
that resides in the current directory. (If you run PROC IML through a SAS Display Manager Session (DMS), you can change the
current directory by selecting → → from the main menu.)
filename MyFile 'MyData.txt'; infile MyFile; show files; closefile MyFile;
Alternatively, you can specify the full path of the file, as shown in the following statements:
src = "C:\My Data\MyData.txt"; infile (src); show files; closefile (src);