BookmarkSubscribeRSS Feed
Pavan_SAS
SAS Employee
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.

how?
3 REPLIES 3
Olivier
Pyrite | Level 9
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).
Pavan_SAS
SAS Employee
%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 !
LinusH
Tourmaline | Level 20
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';
quit;

%symdel &userMac UserMac;

proc sql;
select * from dictionary.macros;
quit;

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

Regards,
Linus
Data never sleeps

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1358 views
  • 0 likes
  • 3 in conversation