DATA Step, Macro, Functions and more

terminating macro references?

SAS Employee
Posts: 73

terminating macro references?

hi all,

how i can terminate all userdefined global and local macro variable references in a sas session?

is there any special keyword or macro function to terminate?

ex: %let a=pavan;

like this so many macro variables created.

after all these creations, i want to terminate all mavro variable values, so that i can use same names for other values.

Super Contributor
Posts: 260

Re: terminating macro references?

Posted in reply to Pavan_SAS
You can use the %SYMDEL macro-instruction. And you can get the user-defined macro-variable names either with dictionary.macros (in a SQL query) or with sashelp.vmacro (in a Data step).
SAS Employee
Posts: 73

Re: terminating macro references?

%let a=pavan;

by using %symdel a; i am deleting that macro variable. its good.

how i can delete all userdefied macro vars?

can i use, %symdel _all_; to delete all?

help me !
Super User
Posts: 5,881

Re: terminating macro references?

Posted in reply to Pavan_SAS
As Olivier pointed out, you can use dictionary.macros/sashelp.vmacro. Try this out:

%let a=Linus;

proc sql noprint;
select name into: userMac separated by ' '
from dictionary.macros
where scope = 'GLOBAL';

%symdel &userMac UserMac;

proc sql;
select * from dictionary.macros;

Beware that this code alse deletes macro variables such as SQLMSG etc.

Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation