How to Delete Macro Variables in SAS?

To delete SAS macro variables, you can use the %SYMDEL statement or the CALL SYMDEL routine.

%SYMDEL and CALL SYMDEL is a data step call routine that is used to delete macro variables from the global symbol table.

How to Delete a single macro variable?

You can use both methods to delete a macro variable.

Delete a macro variable with the CALL SYMDEL  Routine

To delete a macro variable using the CALL SYMDEL, use the macro variable name within quotes in the Call routine.


CALL SYMDEL(macro-variable<, option>);


%let mvar = xyz;
data _null_;
	call symdel('mvar');

Note that CALL SYMDEL issues a warning when an attempt is made to delete a non-existent macro variable. To suppress this message, use the NOWARN option. call symdel('mvar')

Delete a macro variable with the %SYMDEL Macro Statement

The %SYMDEL routine deletes the specified variable from the macro global symbol table.


%SYMDEL variable-name ;

%SYMDEL statement gives a warning when an attempt is made to delete a non-existent macro variable. To suppress this warning in the log, you can use the NOWARN option.

%symdel variable-name / nowarn;


%let mname = ABC;
%put &mname;
%symdel mname;
%put &mname

Key Takeaway

So, this is the way you can delete macro variables in SAS. We really hope that you must have found it useful.

Moreover, if you have any other suggestions regarding other tips or tricks to add then suggest us below the comment section. We would really take those lists in our further blog post.

Thanks for reading!

If you liked this article, you might also want to read CALL SYMPUT in SAS and Creating macro variables from the SAS dataset as well.

Do you have any tips to add Let us know in the comments?

Please subscribe to our mailing list for weekly updates. You can also find us on Instagram and Facebook.

Every week we'll send you SAS tips and in-depth tutorials


Subhro Kar is an Analyst with over five years of experience. As a programmer specializing in SAS (Statistical Analysis System), Subhro also offers tutorials and guides on how to approach the coding language. His website, 9to5sas, offers students and new programmers useful easy-to-grasp resources to help them understand the fundamentals of SAS. Through this website, he shares his passion for programming while giving back to up-and-coming programmers in the field. Subhro’s mission is to offer quality tips, tricks, and lessons that give SAS beginners the skills they need to succeed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap