forked from sasutils/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileref.sas
39 lines (31 loc) · 1.69 KB
/
fileref.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
%macro fileref
/*----------------------------------------------------------------------------
Verify whether a fileref has been assigned
----------------------------------------------------------------------------*/
(fileref /* Fileref to test */
);
/*----------------------------------------------------------------------------
A value of zero indicates that the fileref and external file both exist.
A negative return code indicates that the fileref exists but the physical file
associated with the fileref does not exist.
A positive value indicates that the fileref is not assigned.
Note that a fileref must be valid SAS name of length 1 to 8. The macro will
return 1 when an invalid fileref parameter is supplied.
----------------------------------------------------------------------------*/
%*----------------------------------------------------------------------------
FILEREF empty or blank value.
-----------------------------------------------------------------------------;
%if %bquote(&fileref)= %then 1;
%*----------------------------------------------------------------------------
FILEREF too long.
-----------------------------------------------------------------------------;
%else %if %length(&fileref) > 8 %then 1;
%*----------------------------------------------------------------------------
FILEREF not a valid SAS name.
-----------------------------------------------------------------------------;
%else %if 0 = %sysfunc(nvalid(&fileref)) %then 1;
%*----------------------------------------------------------------------------
Return result of the FILEREF() function.
-----------------------------------------------------------------------------;
%else %sysfunc(fileref(&fileref)) ;
%mend fileref;