<?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 Obtain a list of all macro functions created in a program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914223#M360242</link>
    <description>&lt;P&gt;How do I dynamically create a list of all macro functions created in a program.&amp;nbsp; I know how to obtain a list of reference macros, but not macro functions.&amp;nbsp; How do I do that?&amp;nbsp; The macro functions are temporary - created everytime the program is run.&amp;nbsp; I'm trying to create&amp;nbsp; documentation for code others run since they have don't have any documentation.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 15:17:39 GMT</pubDate>
    <dc:creator>SAJ251</dc:creator>
    <dc:date>2024-02-02T15:17:39Z</dc:date>
    <item>
      <title>Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914223#M360242</link>
      <description>&lt;P&gt;How do I dynamically create a list of all macro functions created in a program.&amp;nbsp; I know how to obtain a list of reference macros, but not macro functions.&amp;nbsp; How do I do that?&amp;nbsp; The macro functions are temporary - created everytime the program is run.&amp;nbsp; I'm trying to create&amp;nbsp; documentation for code others run since they have don't have any documentation.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914223#M360242</guid>
      <dc:creator>SAJ251</dc:creator>
      <dc:date>2024-02-02T15:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914229#M360243</link>
      <description>&lt;P&gt;"functions"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to scan code to see if it defines any macros look for the %MACRO statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to check after running a program what macros are defined you can look at the WORK.SASMACR (or SASMAC1 if using Enterprise Guide or SAS/Studio or other esoteric way to submit SAS code) and see what macro entries are there.&amp;nbsp; For an example of how to do that look at this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/maclist.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/maclist.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914229#M360243</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T15:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914231#M360244</link>
      <description>&lt;P&gt;Do you mean all macro definitions in a program?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you do you mean by reference macros and macro functions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since SAS programs are text files, you could use SAS (or something else) to parse a .sas file to look for %macro statements and grab them name of each macro, but it would be a bit of an exercise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option might be to turn on logging options like MCOMPILENOTE which will write to the log when a macro is compiled.&amp;nbsp; Then you could run a program, and save the log,&amp;nbsp; and then parse the log to see which macros were compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But either way seems kind of messy.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914231#M360244</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-02T15:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914234#M360246</link>
      <description>&lt;P&gt;I like Tom's idea of checking WORK.SASMACR.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could write a macro, %ReportMacrosUsed which will look in WORK.SASMACR and get a list of all of the macros there, and write that list and the name of the program somewhere useful (a file, database, email, whatever).&amp;nbsp; Then tell all of your users to add a call to&amp;nbsp;%ReportMacrosUsed to the end of their programs.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914234#M360246</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-02T15:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914235#M360247</link>
      <description>&lt;P&gt;you could try like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table Before_processing as
  select memname, objname, objtype
  from dictionary.catalogs
  where 
  objtype = "MACRO"
  and libname  = "WORK"
  ;
quit;


/*
your code goes here
*/
/*For example:*/
/* packages to be loaded at the system start */
filename packages "C:\SAS_WORK\SAS_PACKAGES";
%include packages(SPFinit.sas);
%loadPackage(BasePlus)





Title "Newly created macros";
proc sql;
  create table After_processing as
  select memname, objname, objtype
  from dictionary.catalogs
  where 
  objtype = "MACRO"
  and libname  = "WORK"
  ;
  select * from After_processing
    except
  select * from Before_processing
  ;
quit;
Title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914235#M360247</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-02T15:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914236#M360248</link>
      <description>&lt;P&gt;You could use the %MACLIST() macro to make a VIEW and then just ask them to print the VIEW at the end of their programs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make the view into some fixed location.&amp;nbsp; Say your company has a SYSTEM library where you store common data for them to use then your admins could run this %MACLIST() call to make the view.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%maclist(out=system.maclist/view=system.maclist)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then the users can add this step to the end of their programs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=system.maclist;
  title "Macros used by this run";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914236#M360248</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T15:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Obtain a list of all macro functions created in a program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914237#M360249</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    options MCOMPILENOTE=ALL;
2
3    %macro test1234();
4    xxx
5    %mend;
NOTE: The macro TEST1234 completed compilation without errors.
      5 instructions 52 bytes.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2024 15:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Obtain-a-list-of-all-macro-functions-created-in-a-program/m-p/914237#M360249</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-02T15:59:24Z</dc:date>
    </item>
  </channel>
</rss>

