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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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