Closing all tables

Hey everyone,
being a sloppy and unqualified SAS-user I sometimes open tables I created (VIEWTABLE) and then forget closing them before running my program again, which causes an error of course. Is there a command I could put at the beginning of my programs that closes all tables that are open?
I googled this, and could not find an answer, so sorry if this is a stupid question!
Thanks in advance!


Ambassador to the humans
%macro closetables; 
%local i; 
  %do i=1 %to 20; 
    dm 'next VIEWTABLE:; end;';

This creates a macro called closetables. If you have 20 or less tables that you are viewing it will close them all. I don't know a way to get a count of how many tables are currently open otherwise we could put that in. But if you stick this at the top of your file then it will close up to 20 tables for you.