5

Say in my main code I have this code block:

%macros hi5;
 %put hi five;
%mend;

%macros helloworld;
  %put hello world;
%mend;

How do I, in SAS Enterprise Guide, display something like this? (via log or via a SAS table)

These are the user defined user macros:

hi5
hello world

(the aim is so that user is able to know what macros are already available to them).

Note: the %put _ALL_ only list all macros variables, not macros (e.g. built with %macros and %mend.)

Atlas7
  • 2,726
  • 4
  • 27
  • 36
  • 1
    All _compiled_ SAS Macros are stored in a catalog names **SASMACR** which is saved in **WORK** with _entry type_ **MACRO**. I would try **PROC CATALOG** , have never tried using this. Hope it helps! – Gaurav Taneja May 10 '16 at 15:44
  • 1
    Hey Gaurav (thanks for suggesting!), I've actually tried `proc catalog cat=work.sasmacr; contents out=_temp; quit;` - on SAS EG it says work.sasmacr doesn't exist. (In my old work place this used to work on base SAS. In new work place I am on Enterprise guide no base SAS). – Atlas7 May 10 '16 at 15:54
  • 1
    Instead of `work.sasmacr` try `SASHELP.VCATALG` ( blatantly copied from https://communities.sas.com/t5/Base-SAS-Programming/Session-compiled-macro-catalog/td-p/77942 ) – Gaurav Taneja May 10 '16 at 16:10

3 Answers3

8

You can get there via PROC CATALOG, or via dictionary.catalogs. The latter will work even if you don't know where they're stored.

proc sql;
  select * 
    from dictionary.catalogs
    where objtype='MACRO';
quit;

That will include the predefined macros in SASHELP, which you can exclude using where libname ne 'SASHELP'.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • Awesome!!! I run the SQL Query with the added `where ... AND libname ne "SASHELP"` - it now shows me the user defined macro. (I didn't know about this `dictionary table` thing before! Learnt something new today thanks!) – Atlas7 May 10 '16 at 16:19
1

When you are running SAS using Enterprise Guide, SAS/Studio or other new fangled access methods the compiled macros that would previously appear in WORK.SASMACR catalog now end up in WORK.SASMAC1. At least in the environments I have explored.

Tom
  • 47,574
  • 2
  • 16
  • 29
0

I'm using proc catalogs

proc catalog cat=xxxxx.sasmacr;contents;run;
stallingOne
  • 3,633
  • 3
  • 41
  • 63