Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to list all available user defined macros in SAS Enterprise Guide?

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.)

like image 898
Atlas7 Avatar asked May 10 '16 15:05

Atlas7


People also ask

Where are SAS macros located?

Re: Finding Location of SAS Macrosrun PROC OPTIONS and look for SASAUTOS in the log. It may give you a hint where to search the macro.

How many types of macros are there in SAS?

Become a Better Data Professional With Simplilearn These are two types of Macro variables, Global, Local, and a Macro program begins with a %MACRO and ends with a %MEND. Some commonly used Macros are - %END, %RETURN, and %PUT.

How do I find the value of a macro in SAS?

You can also use a %PUT Macro Statement to view available macro variables. %PUT provides several options that enable you to view individual categories of macro variables. The system option SYMBOLGEN displays the resolution of macro variables.

How do you define a macro in SAS?

The %MACRO statement begins the definition of a macro, assigns the macro a name, and can include a list of macro parameters, a list of options, or both. A macro definition must precede the invocation of that macro in your code. The %MACRO statement can appear anywhere in a SAS program, except within data lines.


1 Answers

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'.

like image 144
Joe Avatar answered Nov 05 '22 03:11

Joe