Chapter Contents

Previous

Next
FILEEXIST

FILEEXIST



Verifies the existence of an external file by its physical name and returns a value

Category: External Files


Syntax
Argument
Details
Examples
See Also

Syntax

FILEEXIST(file-name)

Argument

file-name
specifies a fully qualified physical filename of the external file in the operating environment. In a DATA step, file-name can be a character string in quotation marks or it can be a DATA ste p variable. In a macro, file-name is a macro variable.


Details

FILEEXIST returns 1 if the external file exists and 0 if the external file does not exist. The specification of the physical name for file-name varies according to the operating environment.

Although your operating environment utilities may recognize partial physical filenames, you must always use fully qualified physical filenames with FILEEXIST.


Examples

This example verifies the existence of an external file. If the file exists, FILEEXIST opens the file. If the file does not exist, FILEEXIST displays a message in the SAS log. Note that in a macro statement you do not enclose chara cter strings in quotation marks.

%if %sysfunc(fileexist(&myfilerf)) %then
    %let fid=%sysfunc(fopen(&myfilerf));
%else
   %put The external file &myfilerf does not exist.;

See Also

Functions:

EXIST
FEXIST
FILENAME
FILEREF
FOPEN


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.