Clear Log and Results Window
Working in SAS, keeping track of the submitted code and interpreting the output is crucial. Consequently, it is crucial to know your log and results viewer well. Sometimes though, they can get messy. Your log can suddenly be filled with millions of lines and your results viewer can contain much information you do not need anymore. Therefore, it is convenient to know how to clean up the mess so you can stay focused on what is important. Here, I will show how to clear the log and results viewer using simple SAS code.
Firstly, let us look at how to clear the SAS log with simple code. I use the DM Statement with LOG ‘CLEAR’ as arguments to clear everything in the current log. Actually, I do the same thing with the output window, though I rarely use it. You can achieve the same result by going to Edit –> Clear All in your editor while having the log active. I like the code method better though.
/* Clean log and output */ dm log "clear"; dm output "clear";
Clear Results Window
You can also clear the HTML results viewer using code in SAS, though the concept is a bit different. Here, we do not use the DM Statement. Rather, we use the ODS Statement to simply close the HTML window and immediately open a new one. The HTML Results Window is the standard destination for ODS output in SAS, though this is only the case from SAS 9.3 and forward. Before that the Listings destination was standard.
ods html close; ods html;
Another trick, I often use when I work in SAS is to force the HTML Results window to show only the results from the latest submitted code or procedure. This can be achieved with the ODS HTML NEWFILE=PROC statement, telling SAS that the HTML destination should only contain output from the latest submitted procedure. This is very useful when you run some procedure multiple times and make small corrections to it. In that case, it can be difficult to navigate to the exact place in the HTML Window of your interest, because a lot of the results will look the same. The small program below does exactly that.
/* Results Window show only last procedure */ ods preferences; ods html close; ods html newfile=proc;
It is often very convenient to clear out the things you do not need, whether it is in your log, results viewer or some third place. I use these tricks very often. That is why, I have added abbreviations in my editor so that I do not have to memorize the code, only what the abbreviation does. The process of adding an abbreviation in your editor is shown in the blog post Standard Header. You can see many other tricks of clearing logs, results and whole libraries in the great article Taking Out the Garbage by Adam LaManna and Howard M. Proskin.
You can download the entire code from this post here.