BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
madara155
Obsidian | Level 7

Hi

I am trying to delete all the macro variables in a program and can't seem to find a method.

Saw that some people have suggested to use %SYMDEL but I don't know how to delete all the macro variables using it.

 

Can someone please help me?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

First, you have to realize that what you requested is not possible.  You can only delete GLOBAL macro variables,  You cannot delete LOCAL macro variables, and you cannot delete AUTOMATIC macro variables that are supplied by the software.  So if deleting GLOBAL macro variables will satisfy what you need to do, here is a link that shows you how:

 

https://www.lexjansen.com/nesug/nesug06/po/po06.pdf

 

The specific example you requested begins at the bottom of page 3.

View solution in original post

4 REPLIES 4
AlanC
Barite | Level 11

Use the following options at the top of the program:

 

options mfile mprint obs=0 noerrorbyabend errors=0 source source2 nonotes;

filename mprint 'c:\temp\SasCode.txt’;

 

When you run your program, a new copy of it will be in the SasCode.txt file with all macros resolved.

https://github.com/savian-net
Astounding
PROC Star

First, you have to realize that what you requested is not possible.  You can only delete GLOBAL macro variables,  You cannot delete LOCAL macro variables, and you cannot delete AUTOMATIC macro variables that are supplied by the software.  So if deleting GLOBAL macro variables will satisfy what you need to do, here is a link that shows you how:

 

https://www.lexjansen.com/nesug/nesug06/po/po06.pdf

 

The specific example you requested begins at the bottom of page 3.

madara155
Obsidian | Level 7

Thanks.

I only wanted to delete the global macro variables I defined.

Regards.

Ksharp
Super User

Use this code to get all the macro variables .and %symdel them all.

 

proc sql;
create table x as
select * from dictionary.macros;
quit;

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 8045 views
  • 1 like
  • 4 in conversation