As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

ListMcat List Macro Catalog

From sasCommunity
Jump to: navigation, search

Utility program developed and described in SASautos_Companion_Reusing_Macros

Author: Ronald_J._Fehd

 /*       Name:
Requirements  :   description: list macros in catalogs
                                    notes written to log
                                    of LibName, MacroName, Description
                      purpose: show masked macros:
                                    two same-named macros
                                    in different catalogs
Context . . . : program group: testing tool for masking:
                                       aka name collision
                program  type: routine
                    SAS  type: program: include w/o parms
Specifications:         input: sql Dictionary.Catalogs
                      process: read from Dictionary.Catalogs
                               putlog  vars
                       output: notes in log
Usage . . . . :
filename SiteIncl '.';
%Include SiteIncl(ListMcat);
see also TestSuite at end of program
Information . :        author: Ronald J. Fehd
change notes:
RJF2 2005Jan23 for SUGI30.267 A SASautos Companion: Reusing Macros
RJF2 2005Jan30 compile&store MemName is always SASmacr
RJF2 2007May10 replace SAShelp.VCATALG with sql Dictionary.Catalogs
%*Let     WidthObjName =  7;%*for demo: length(objname) = 7;
/*...................................... */
%Let      OptLinesize  = %sysfunc(getoption(linesize,keyword));
%Let      WidthObjName = 32;%*max width macro name::ObjName;
options   nonotes linesize = max;
PROC SQL; create   table  Work.CatalogEntries as
          select * from   Dictionary.Catalogs
                   where  MemName eq 'SASMACR'
                   order  by ObjName, LibName;
DATA _Null_;
*ruler for column value assignments
*   .    1    .    2    .    3    .    4    .    5
.  .5.  .0.  .5.  .0.  .5.  .0.  .5.  .0.  .5.  .01234
ListMcat: List Macros in Catalog(s)
libname8 objname8901234567890123456789012  objdesc
LIBRARY  TESTY                             TestY      *end ruler;
retain  C1 1            C2 10              C3 44;
        C3 = sum(C2,&WidthObjName.,2);
if      "%sysfunc(getoption(SASmstore))" ne " " then putlog
        "ListMcat: SASmStore = %sysfunc(getoption(SASmstore))";
putlog  'ListMcat: List Macros in Catalog(s)'
     /  @C1 'libname'  @C2 'objname'      @C3 'objdesc';
do      until(EndoFile); 
        set    Work.CatalogEntries end = EndoFile;
        by     ObjName LibName;
        if     first.ObjName and not last.ObjName then putlog /
               @C1 'Er' 'ror: ' @C2 ObjName 'is masked';
        putlog @C1 LibName      @C2 ObjName @C3 ObjDesc;
        if     last.ObjName and not first.ObjName then putlog ;
PROC    Delete data = Work.CatalogEntries;
options notes &OptLineSize.;
%SymDel        OptLineSize  WidthObjName; 

This program will give you two lists:

PROC Catalog catalog = Work.sasmacr;
libname Library '<directory-specification>';
PROC Catalog catalog = Library.sasmacr;

--Ronald_J._Fehd macro.maven == the radical programmer 10:37, 31 January 2009 (EST)