forked from sasutils/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maclist.sas
75 lines (69 loc) · 2.57 KB
/
maclist.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
%macro maclist
/*----------------------------------------------------------------------
Generate list of compiled macros and their source directories
----------------------------------------------------------------------*/
(out=maclist /* Name of dataset to generate */
,dlist= /* Directory list to scan (default=SASAUTOS option) */
);
/*----------------------------------------------------------------------
Produce a summary dataset with the location of the source file for the
compiled macros currently in SASHELP.SASMACR catalog by scanning across
SASAUTOS search path to see if corresponding file exists.
When using SAS 9.2 or higher it will use to Q modifier on the SCAN()
function to allow pathnames to include parentheses when properly quoted.
----------------------------------------------------------------------*/
data &out ;
attrib MACRO length=$32 label='Macro name';
attrib FOUND length=3 label='Found? (0/1)';
attrib FILE length=$36 label='Filename';
attrib DNAME length=$200 label='Directory name';
keep macro found file dname;
if _n_=1 then do;
*----------------------------------------------------------------------;
* Get SASAUTOS option into string variable and copy individual paths ;
* into DLIST, expanding any filerefs that are found (such as SASAUTOS).;
*----------------------------------------------------------------------;
length dlist autos path $32767 ;
retain dlist ;
%if %length(&dlist) %then %do;
autos=%sysfunc(quote(&dlist));
%end;
%else %do;
autos=getoption('sasautos');
%end;
do i=1 by 1 until (path= ' ');
%if %sysevalf(9.2 <= &sysver) %then %do;
path=scan(autos,i,'( )','q');
%end;
%else %do;
path=scan(autos,i,'( )');
%end;
if length(path) <= 8 then do;
if 0=fileref(path) then path=pathname(path) ;
end;
dlist=left(trim(dlist)||' '||path);
end;
end;
set sashelp.vcatalg;
where libname='WORK' and memname='SASMACR'
and memtype='CATALOG' and objtype='MACRO';
macro=objname;
file=lowcase(trim(macro))||'.sas';
*----------------------------------------------------------------------;
* Scan through the paths in DLIST until file found or end of list ;
*----------------------------------------------------------------------;
found=0;
done=0;
do i=1 by 1 until (found or done);
%if %sysevalf(9.2 <= &sysver) %then %do;
dname=dequote(scan(dlist,i,'( )','q'));
%end;
%else %do;
dname=dequote(scan(dlist,i,'( )'));
%end;
if dname=' ' then done=1;
else if fileexist(trim(dname)||'/'||trim(file)) then found=1;
end;
if ^found then dname=' ';
run;
%mend maclist;