As the first step in the decommissioning of sasCommunity.org 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
Revision as of 14:51, 31 May 2015 by Ron.Fehd.macro.maven (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Utility program developed and described in SASautos_Companion_Reusing_Macros

Author: Ronald_J._Fehd

 /*       Name: ListMcat.sas
 
------------------------------------------------------------------------
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
http://www2.sas.com/proceedings/sugi30/267-30.pdf
http://www.sascommunity.org/mwiki/images/1/13/SUGI30-267.zip
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;
          quit;
 
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 ;
        end;    
stop;   
run;
 
PROC    Delete data = Work.CatalogEntries;
 
options notes &OptLineSize.;
%SymDel        OptLineSize  WidthObjName; 
run;

This program will give you two lists:

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

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