-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexistfile.sas
59 lines (44 loc) · 1.92 KB
/
existfile.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%macro ExistFile(file) / des="Check if file exists";
/********************************************************************************
BEGIN MACRO HEADER
********************************************************************************
Name: ExistFile
Author: Chris Swenson
Created: 2009-10-23
Purpose: Check if file exists
Arguments: file - file to check
Revisions
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Date Author Comments
¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯
YYYY-MM-DD III Please use this format and insert new entries above
********************************************************************************
END MACRO HEADER
********************************************************************************/
/* Check argument */
%if %superq(file)=%str() %then %do;
%let nofile=1;
%put %str(E)RROR: The file was not specified.;
%goto exit; /* Restore options and exit */
%end;
%local user_mprint;
%let user_mprint=%sysfunc(getoption(mprint));
options nomprint;
/* Check directory */
%if %sysfunc(fileexist( %substr(%superq(FILE), 1, %eval( %length(%superq(FILE)) - %length( %scan(%superq(FILE), -1, %str(\)) ) )) ))=0
%then %do;
%put %str(E)RROR: The specified directory does not exist.;
%goto exit; /* Restore options and exit */
%end;
/* Assume File Exists */
%global nofile;
%let nofile=0;
/* Check that the specified directory exists, if not change nofile */
%if %sysfunc(fileexist("%superq(FILE)"))=1 %then %put NOTE: The specified file exists.;
%else %do;
%let nofile=1;
%put %str(E)RROR: The specified file does not exist.;
%end;
%exit:
options &user_mprint;
%mend ExistFile;