27 %MACRO _crossreference(i_includeSASUnit =0
51 %IF &g_verbose. =0 %THEN %DO;
52 %let l_source =%sysfunc(getoption(source));
53 %let l_notes =%sysfunc(getoption(notes));
54 %let l_mprint =%sysfunc(getoption(mprint));
56 options nomprint nonotes nosource;
60 %IF &i_includeSASUnit. ne 0 %THEN %LET l_includeSASUnit=1;
61 %ELSE %LET l_includeSASUnit=0;
67 IF index(filename,
'.sas') = 0 THEN
delete;
68 loca = length(filename) - length(scan(filename,-1,
'/')) + 1;
69 name = substr(filename,loca);
70 name = substr(name, 1, length(name)-4);
74 PROC SORT DATA=&o_macroList. NODUPKEY;
83 SET &o_macroList. end=eof;
84 Call Symputx(catt(
"var",i), name);
85 Call Symputx(
'l_name',name);
87 IF eof THEN Call Symputx(
"l_count",i);
93 length caller called $ 80
100 %IF &l_includeSASUnit. = 0 %THEN %DO;
102 select tsu_sasunit_os into: l_sasunit_os
107 %LET l_path1 = %_abspath(&g_root,&g_sasunit)/%;
108 %LET l_path2 = %_abspath(&g_root,&l_sasunit_os)/%;
109 *** Omit SASUnit macropaths ***;
111 SET &o_macroList.(WHERE=(filename not like
"&l_path1" AND filename not like
"&l_path2"));
117 %DO %WHILE (&l_loop);
121 Modify &o_macroList.(Where=(filename NE
''));
122 Call Symputx(
'l_filename',filename);
123 Call Symputx(
'l_name',name);
124 Call Symputx(
'l_loop' ,1);
130 %IF &l_loop %THEN %DO;
135 retain pattern1 ptrn_Com_1_o ptrn_Com_1_c;
136 retain l_DoxyHeader 0 comment 0;
139 pattern1 = prxparse(
'/%/');
140 ptrn_Com_1_o = prxparse(
'/\/\*/');
141 ptrn_Com_1_c = prxparse(
'/\*\//');
144 INFILE
"&l_filename" truncover;
146 line = trim(left(_infile_));
149 fnt_o = prxmatch(ptrn_Com_1_o, line);
151 IF fnt_o > 0 and comment = 0 THEN DO;
152 fnt_c = prxmatch(ptrn_Com_1_c, line);
154 IF fnt_c > 0 THEN DO;
155 IF fnt_o = 1 THEN line = substr(line, fnt_c+2);
156 ELSE line = catt(substr(line,1,fnt_o-1), substr(line, fnt_c+2));
160 ELSE IF fnt_c = 0 THEN DO;
161 IF fnt_o = 1 THEN line =
"";
162 ELSE line = substr(line,1,fnt_o-1);
167 ELSE IF comment = 1 THEN DO;
168 fnt_c = prxmatch(ptrn_Com_1_c, line);
170 IF fnt_c = 0 THEN line =
"";
172 line = substr(line, fnt_c+2);
178 IF prxmatch(pattern1, line) THEN DO;
180 called = resolve(catt('&var',x));
181 calledMacro = catt('%',called);
182 findpos = find(line, trim(calledMacro), 'i');
184 IF findpos gt 0 THEN DO;
185 len = length(trim(calledMacro));
187 substring = substr(line, findpos+len,1);
188 IF substring in ('(',' ',';') THEN DO;
189 caller = resolve("&l_name");
190 KEEP line caller called;
199 SET helper nobs=cnt_obs;
200 call symput('l_nobs', put(cnt_obs, 4.));
203 %IF &l_nobs GT 0 %THEN %DO;
205 PROC sort DATA = helper nodupkey;
209 PROC append base=&o_listcalling DATA=helper;
210 where caller ne called;
218 create table stage1 as
219 select distinct caller, called
220 from &o_listcalling as l1
222 select count(caller) into: nobs
232 %DO %while (&l_loop);
233 %LET nobs_old = &nobs.;
234 %LET n = %eval(&n. + 1);
237 create table stage&n. as
238 select distinct s.caller, l.called
239 from stage%eval(&n.-1) as s
240 join &o_listcalling. as l
241 on s.called = l.caller
245 set stage&n. stage%eval(&n.-1);
247 proc sort data=stage&n. noduplicate;
251 select count(caller) into: nobs
255 %IF &nobs eq &nobs_old %THEN %LET l_loop=0;
261 keep caller calledByCaller;
262 caller = catt(caller,".sas");
263 cnt = count(called,',');
265 calledByCaller = catt(scan(called,i,','),".sas");
270 PROC SORT DATA=&o_dependency NODUPKEY;
271 BY caller calledByCaller;
274 %IF &g_verbose =0 %THEN %DO;
275 options &l_source &l_notes &l_mprint;
277 %MEND _crossreference;