Here's a starting point for you. This data step reads a SAS dataset file, finds macro calls and %INCLUDE statements, and creates a dataset that includes the program name and the macros calls.
%let myProgram=C:\temp\test.txt;
data calls;
infile "%superq(myProgram)" end=lastrec;
length Program $256 MacroName $32;
retain rxID;
retain Program "%qscan(%superq(myProgram),-1,\/)";
drop rxID count;
if _n_=1 then do;
rxID=prxparse('/(%(?!(macro|mend))\s*\w*)/i');
end;
input;
if prxmatch(rxID,_infile_) then do;
MacroName=prxposn(rxID,1,_infile_);
output;
count+1;
end;
if lastrec and count=0 then do;
put 'NOTE- ************************************************';
put 'NOTE: No macro calls or %INCLUDEs in program ' program ;
put 'NOTE- ************************************************' ;
end;
run;
proc sql;
select distinct program, macroName
from calls
;
quit;
Here are a couple of test "programs" to play with. Save them as test.sas and test2.sas
/* test.sas */
%macro include;
%mend myMacro;
%myMacro
%include "c:\temp";
%include fileref;
print "This is a %test";
/*test2.sas */
macro include;
mend myMacro;
myMacrol
include "c:\temp";
include fileref;
print "This is a test";
When executed against test.sas, this is the result:
Program
MacroName
test.sas
%include
test.sas
%myMacro
test.sas
%test
May the SAS be with you!
Mark
... View more