To delete SAS macro variables, you can use the %SYMDEL statement or the CALL SYMDEL routine.
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'); run;
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.
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
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!
Do you have any tips to add Let us know in the comments?