<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to know the list of code/macros files been included/referenced in the sas code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-the-list-of-code-macros-files-been-included/m-p/799086#M314182</link>
    <description>&lt;P&gt;Can we have a sas code to get the list of files that sas code is referring to while executing. For Eg: the macros it is referring or the files that has been included in the sas code through out the flow.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Feb 2022 06:55:38 GMT</pubDate>
    <dc:creator>Anupama29</dc:creator>
    <dc:date>2022-02-28T06:55:38Z</dc:date>
    <item>
      <title>How to know the list of code/macros files been included/referenced in the sas code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-the-list-of-code-macros-files-been-included/m-p/799086#M314182</link>
      <description>&lt;P&gt;Can we have a sas code to get the list of files that sas code is referring to while executing. For Eg: the macros it is referring or the files that has been included in the sas code through out the flow.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 06:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-the-list-of-code-macros-files-been-included/m-p/799086#M314182</guid>
      <dc:creator>Anupama29</dc:creator>
      <dc:date>2022-02-28T06:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the list of code/macros files been included/referenced in the sas code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-know-the-list-of-code-macros-files-been-included/m-p/799122#M314198</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%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;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are a couple of test "programs" to play with. Save them as test.sas and test2.sas&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* test.sas */
%macro include;
%mend myMacro;
%myMacro
%include "c:\temp";
%include fileref;
print "This is a %test";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*test2.sas */
macro include;
mend myMacro;
myMacrol
include "c:\temp";
include fileref;
print "This is a test";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When executed against test.sas, this is the result:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;Program&lt;/TH&gt;
&lt;TH class="l b header" scope="col"&gt;MacroName&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;test.sas&lt;/TD&gt;
&lt;TD class="l data"&gt;%include&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;test.sas&lt;/TD&gt;
&lt;TD class="l data"&gt;%myMacro&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;test.sas&lt;/TD&gt;
&lt;TD class="l data"&gt;%test&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P class="lia-align-left"&gt;May the SAS be with you!&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Mark&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Feb 2022 13:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-know-the-list-of-code-macros-files-been-included/m-p/799122#M314198</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2022-02-28T13:51:09Z</dc:date>
    </item>
  </channel>
</rss>

