BookmarkSubscribeRSS Feed

Please add an Additional Column in the view SASHELP.VMACRO  ( also  to table DICTIONARY.MACROS)  to Identify User Defined Macro Variables .User Defined here refers to ONLY Macro Variables defined in the SAS Code.


The Column may be named : UserDefined with values of Y or N. Therefore if a User wants to know the list of Macro variables defined up until a certain Step in the SAS Code he can simply use the below Code :



Proc Sql;
 where UserDefined='Y'; 


Opal | Level 21

It may not be obvious, but I think you already have this ability.  The dictionary table (dictionary.macros, which should have the same structure as sashelp.vmacro) contains a variable named SCOPE.  It takes on values of AUTOMATIC (for system-generated macro variables) and either GLOBAL or LOCAL (for user-generated macro variables).

Pyrite | Level 9

@Astounding   Thank you for your Comment. Actually i did  look into  it before posting this Idea.  But  there are few  GLOBAL  Macro variables which  are  system defined and cannot  be deleted  .My aim is  to   identify  ONLY  the  "User Defined" Macro variables.Also  i  do not see a value  of LOCAL   for "Scope"  in the  VMACRO  view  when i create a Macro variable. It is actually captured under  GLOBAL Scope.

Opal | Level 21

The only ones that I've seen like that are the ones created by running PROC SQL.  It might make sense for those to have a unique value for SCOPE.  Are there any others that you have encountered?

Pyrite | Level 9

Yes .  when  i run SAS Code on  Clients  such  as SAS EG  i get additional  GLOBAL  macro variables  as shown below.



Barite | Level 11

The solition of an addtional column in sashelp.vmacro won't help much.
What really is needed is some addtional core attribute wiht a macro indicating owner/goal.  That is some metadata architecture.

A naming covnention could help is some standardisation but is very hard to be agreed and followed by everyone (MXG?)

Calcite | Level 5
If you are using a version of SAS that supports %put _user_ here is a do-it-yourself way to get a list of user-defined macro vars: 1. redirect the log to a temporary file (or catalog entry in work), 2. run %put _user_ ; 3. restore log to default location; 4. use a data step to parse the temporary file. The output of %put _user_ not only lists user-defined variables but identifies whether they are global or which macro scope they belong to if they are local. Should be easy to make a standard macro to do this.