Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mfv_existfile.sas File Reference

Checks whether a file exists in SAS Drive. More...

Go to the source code of this file.

Detailed Description

Returns 1 if the file exists, and 0 if it doesn't. Works by attempting to assign a fileref with the filesrvc engine. When the file is not found the filename function sets syscc to a non zero value, so the macro resets syscc to zero and returns 0.

A non zero syscc on entry means an earlier step has already failed. The macro logs a str(ERR)OR: line and returns 0 without touching syscc, so a caller comparing the result against 1 or 0 stays valid, and can tell this case from a genuine miss by checking syscc, which a miss resets to zero.

Usage:

%put %mfv_existfile(/does/exist.txt);
%put %mfv_existfile(/does/not/exist.txt);
Parameters
[in]filepathThe full path to the file on SAS drive (eg /Public/myfile.txt)

SAS Macros

Related Macros

Version
3.5
Author
Allan Bowe

Definition in file mfv_existfile.sas.