FCLOSE Function


Closes an external file, directory, or directory member

Category: External Files

See: FCLOSE Function in the documentation for your operating environment.

Syntax

FCLOSE ( file-id )

Argument

file-id

  • specifies the identifier that was assigned when the file was opened, generally by the FOPEN function.

Details

FCLOSE returns a 0 if the operation was successful and ‰  0 if it was not successful. If you open a file within a DATA step, it is closed automatically when the DATA step ends.

Operating Environment Information: On some operating environments you must close the file with the FCLOSE function at the end of the DATA step. For details, see the SAS documentation for your operating environment.

Examples

This example assigns the fileref MYFILE to an external file, and attempts to open the file. If the file is opened successfully, indicated by a positive value in the variable FID, the program reads the first record, closes the file, and deassigns the fileref:

 %let filrf=myfile;  %let rc=%sysfunc(filename(filrf,  physical-filename  ));  %let fid=%sysfunc(fopen(&filrf));  %if &fid > 0 %then     %do;        %let rc=%sysfunc(fread(&fid));        %let rc=%sysfunc(fclose(&fid));     %end;  %else     %do;        %put %sysfunc(sysmsg());  %end;  %let rc=%sysfunc(filename(filrf)); 

See Also

Functions:

  • 'DCLOSE Function' on page 484

  • 'DOPEN Function' on page 503

  • 'FOPEN Function' on page 550

  • 'FREAD Function' on page 558

  • 'MOPEN Function' on page 656




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net