clearmv.sas
/*
* Richard A. DeVenezia
* 6/16/1999
*
* Use %symdel mvar in version 8.2+
*/
%macro clearmv;
%local __dsid__ __rc__ __mvar__;
%let __dsid__ = %sysfunc (open (SASHELP.VMACRO(where=(scope='GLOBAL'))));
%if &__dsid__ %then %do;
%do %while (0 = %sysfunc (fetch (&__dsid__)));
%let __mvar__ = %sysfunc (getvarc(&__dsid__,2));
%if (&__mvar__ eq __DSID__ or &__mvar__ eq __RC__ or &__mvar__ eq __MVAR__)
%then
%put WARNING: &__mvar__ cannot be cleared.;
%else
%let &__mvar__=;
%end;
%let __rc__ = %sysfunc (close(&__dsid__));
%end;
%else
%put ERROR: Could not open SASHELP.VMACRO;
%mend clearmv;
/*
%let x=2;
%put x=&x;
%clearmv;
%put x=&x;
%symdel x;
%put x=&x;
*/