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.

Listing Macros in SASautos

From sasCommunity
Jump to: navigation, search

Q: How do I get a list of the SAS-supplied macros?

A: There are one or macros stored in each file in the sasmacro folder under each product you have licensed.


  1. Read the list of files in each <product-name>\sasmacro folder.
  2.  %Include the files, and check the catalog sasmacr.

Here is the [list of 502 macros] (in 311 files in 13 folders) available in v9.1.3. Tip: you can download the list and open it as a spreadsheet; renaming the file from -csv.txt to .csv may streamline the process for you.


SQL Dictionaries


PROC SQL; describe table Dictionary.Catalogs;
NOTE: SQL table DICTIONARY.CATALOGS was created like:

   libname char(8) label='Library Name',
   memname char(32) label='Member Name',
   memtype char(8) label='Member Type',
   objname char(32) label='Object Name',
   objtype char(8) label='Object Type',
   objdesc char(256) label='Object Description',


PROC SQL; describe table Dictionary.ExtFiles;
   fileref char(8) label='Fileref',
   xpath char(1024) label='Path Name',
   xengine char(8) label='Engine Name'


*name: SASautos-to-library;
* instantiate fileref SASautos;
%Include sasautos(af);
PROC SQL noprint;
         create table Library.ListXpath as
         select FileRef, Xpath
         from   Dictionary.ExtFiles
         where  fileref eq 'SASAUTOS';
* name: filelist-caller;
Proc Delete data = Library.ListFilenames;
%Let CxData    = Library.ListXpath;
%Let CxInclude = Project(FileList);
%Include Project(CallXInc);
Proc Print data = &SysLast.;
Proc Freq data   = &SysLast.;
          tables   XPath
                 / list;
Fehd: listing filenames and macros in fileref SASautos
                                                                 Cumulative  Cumulative
Xpath                                          Frequency  Percent Frequency    Percent
---------------------------------------------- ---------  -----------------------------
C:\Program Files\SAS\SAS 9.1\access\sasmacro         30     9.65        30       9.65
C:\Program Files\SAS\SAS 9.1\assist\sasmacro          5     1.61        35      11.25
C:\Program Files\SAS\SAS 9.1\core\sasmacro          157    50.48       192      61.74
C:\Program Files\SAS\SAS 9.1\dquality\sasmacro        3     0.96       195      62.70
C:\Program Files\SAS\SAS 9.1\eis\sasmacro            35    11.25       230      73.95
C:\Program Files\SAS\SAS 9.1\ets\sasmacro            21     6.75       251      80.71
C:\Program Files\SAS\SAS 9.1\gis\sasmacro             5     1.61       256      82.32
C:\Program Files\SAS\SAS 9.1\graph\sasmacro          11     3.54       267      85.85
C:\Program Files\SAS\SAS 9.1\iml\sasmacro             2     0.64       269      86.50
C:\Program Files\SAS\SAS 9.1\inttech\sasmacro         2     0.64       271      87.14
C:\Program Files\SAS\SAS 9.1\or\sasmacro             16     5.14       287      92.28
C:\Program Files\SAS\SAS 9.1\qc\sasmacro              4     1.29       291      93.57
C:\Program Files\SAS\SAS 9.1\share\sasmacro           3     0.96       294      94.53
C:\Program Files\SAS\SAS 9.1\stat\sasmacro           17     5.47       311     100.00
* for each file:;
* %Include 'fileref\';
* parse catalog;

List Processing

The program is available in the SmryEachVar, v2, .zip.

and has its own page: Call_Execute_Parameterized_Include

* name: IncludeFileName-caller;
%Let CxData = Library.ListFiles;
%Let CxInclude = Project(IncludeFileName);
%Include Project(CallXinc);
* name       : IncludeFileName;
* description: include path/filename;
*              copy work.SASmacro.catalog;
*              add  variables of parameters;
* purpose    : one step in buillding list of macro names in filenames;
* author     : Ronald J. Fehd;
* reference  : A SASautos Companion;
*              ;
%Include "&Xpath.\&" /nosource2;
PROC SQL noprint;
         create table Work.MacroNames as
         select Libname, Memname, Memtype, ObjName, ObjType, ObjDesc
         from   Dictionary.Catalogs
         where  LibName eq 'WORK'
           and  MemName eq 'SASMACR'
           and  MemType eq 'CATALOG'
           and  ObjType eq 'MACRO';
* add fileref, xpath, Filename;
DATA Work.MacroNames;
     attrib Fileref  length = $   8
            xpath    length = $1024
            Filename length = $  32
     retain Fileref  "&FileRef."
            Xpath    "&Xpath."
            Filename "&Filename.";
do until(EndoFile);
   set Work.MacroNames
      (keep   =  ObjName
       rename = (ObjName = Macro))
       end    = EndoFile;
Proc Append base = Library.MacroNames
            data =    Work.MacroNames;
2008-Jul-22 RJF2 knot works: cannot wipe catalog in job
* delete all entries in catalog;
PROC Catalog catalog = Work.SASmacr kill;
* name: IncludeFileName-Test;
options source2;
Proc Delete data = Library.MacroNames;
%Let FileRef  = SASautos;
%Let Xpath    = C:\Program Files\SAS\SAS 9.1\core\sasmacro;
%Let Filename = annomac;
%Include Project(IncludeFileName);
Proc Print data = Library.MacroNames;
* print report;
PROC Print data = Library.MacroNames;
           by     Fileref Xpath Filename;
           id     Fileref Xpath Filename;
Fileref                     xpath                     Filename  Macro

SASautos  C:\Program Files\SAS\SAS 9.1\core\sasmacro  annomac   ANNOMAC 
SASautos  C:\Program Files\SAS\SAS 9.1\core\sasmacro  annomac   AREATAG 
SASautos  C:\Program Files\SAS\SAS 9.1\core\sasmacro  annomac   TXT2CNTL


see also: SASautos_Companion_Reusing_Macros

-- created by User:Rjf2 15:49, 21 July 2008 (EDT)

--Ronald_J._Fehd macro.maven == the radical programmer