Tuesday, October 3, 2017

Easy way to check the file existence

SAS doc suggests "You can use SYSFILRC to confirm that a file or location is allocated before attempting to access an external file". I have not tested if it will work with special file but it works well with regular ones.

16   filename a "c:\";
17   %put &=sysfilrc;  /* file exists. */
SYSFILRC=0
18
19   filename b "c:\_not_exist";
20   %put &=sysfilrc; /* file does not exist. */
SYSFILRC=1

No comments: