*Macro to clear out the log screen, output screen, remove all libname references other than the starting 5, clear out titles and footnotes, and clear certain catalogs; %macro restart(exclude= /*Default list*/, logclear=Y /*If Y then clear log */, outputclear=Y /*If Y then clear output screen */, titleclear=Y /*If Y then clear title*/, footclear=Y /*If Y then clear footnote*/, workclear=Y /*If Y then clear work */, formatclear=Y /*If Y then clear formats */, macroclear=Y /*If Y then clear out all macros*/, resultclear=Y /*If Y then clear out the output sceen and the results window*/); %*Get all libnames other than the core 5 and put them into a datalist; %*Keep a running count of the number of libnames; data libs; retain count; set Sashelp.vslib end=eof; where libname not in ('ACTIV' 'BIBLIO' 'SASHELP' 'SASUSER' 'WORK' &exclude); count+1; call symput(compress('new'||left(count)),libname); if eof then call symput('new',count); rename libname=lib; keep libname count; run; %*Find out if there were indeed any other libnames other than the core 5; proc sql noprint; select nobs into :bnobs from Sashelp.Vtable where libname eq 'WORK' and memname eq 'LIBS'; quit; %*If there were other libnames, then clear them and delete the macro variable; %if &bnobs ge 1 %then %do i=1 %to &new; libname &&new&i clear; %symdel new&i; %end; %*To delete all temp datasets in work directory; %if &workclear=Y %then %do; proc datasets lib=work memtype=data kill; run; quit; %end; %*To delete all formats in work directory; %if &formatclear=Y %then %do; proc datasets memtype=catalog; delete formats; run; quit; %end; %*To delete all macros in sasmacr catalog in work directory except restart macro; %if ¯oclear=Y %then %do; proc catalog catalog=work.sasmacr force; save restart/et=MACRO; run; quit; %end; %*To delete all titles; %if &titleclear=Y %then %do; title1; %end; %*To delete all footnotes; %if &footclear=Y %then %do; footnote1; %end; %*To delete log; %if &logclear=Y %then %do; dm log "clear"; %end; %*To delete output; %if &outputclear=Y %then %do; dm output "clear"; %end; %*To delete output and results window; %if &resultclear=Y %then %do; dm "odsresults" clear; %end; %symdel bnobs new/NOWARN; %mend; *Uncomment next line if debugging is needed; *options mlogic mprint symbolgen;