One of the highly visible changes in SAS 9.3 is the fact that the old LISTING destination is no longer the default destination for ODS output. Instead, the HTML destination is the default.
One positive consequence of this is that ODS graphics and tables are interlaced in the output. Another is that complicated tables are easier to read because SAS can use styles (colors, fonts, and cell shading) to make tables more readable. For example, the row and column headings of a table might be a different color than the cells of the table.
However, if you are like me, you occasionally like to clear the output window so that it doesn't get too crowded. In SAS 9.2, clearing the Output Window (by which I mean the LISTING destination) in the SAS Windowing Environment was easy: select Edit > Clear All or select the Output Window and click the New icon (or File > New).
I assumed that I could clear the HTML Results Viewer in SAS 9.3 the same way, but as the following image shows, the Edit > Clear All menu item is disabled!
No worries, though. You can clear the Results Viewer programmatically by submitting the following statements:
ods html close; /* close previous */ ods html; /* open new */ |
The Results Viewer will not immediately look empty, but the next time that you generate output you will see that the Results Viewer no longer includes the older content.
There is a SAS Usage Note that describes other ways to clear the contents of the Results Viewer. Thanks to the fine folks on the SAS-L Mailing List for asking this question and for linking to the SAS Knowledge Base article.
Update, Fall 2012: This problem is FIXED at SAS 9.3M2 (the 12.1 release for SAS/STAT, SAS/ETS, SAS/IML, etc.). At 9.3M3 you can just choose Edit > Clear All from the main menu and the HTML output is cleared. *Phew!*
36 Comments
This works OK, better than the Usage note you linked to. But neither is really adequate-- your approach requires a lot of typing, and the usage not makes a lot of files. What's really needed is a button, or a worst a function-key mappable command.
It would be fine to tie your approach to a function key-- is there a way to use SAS statements in the definitions in the KEYS window? This used to be possible with %keydef, but its not obvious that this can be done anymore.
The macro
%macro clearoutput;
ods html close;
ods html;
%mend clearoutput;
works fine. I can just store it permanently, but I'd still have to use a lot of keystrokes. I really want to associate it with a function key or a button. Do you know of a way to do that?
Got it-- the gsubmit command.
If you open the keys window (or customize a tool) to read
gsubmit "ods html close; ods html;"
then the key (or toolbar button) will shut the (current) html output file and open a new one. It doesn't clear the results viewer, or, I think, delete the old file. Which could prove useful, occasionally.
Step-by-step instructions: http://kenkleinman.net/home/index.php/sas-and-r-code/sas-tricks/77-clear-the-results-viewer-in-sas-93.html
appreciate the tip. very helpful!
Thanks, Ken, for your very helpful step-by-step instructions. I did find that I had to click my new "clear results" icon each time before running a new script, but this figures to reason since some times I would want to keep the older results. Thanks again.
I used the step by step instructions. It didn't work, so I deleted the ods statement from F12. Now I can't even see my results. I get the warning "No output destination active". What did I do wrong?
If you followed Ken's instructions, contact him. Or contact SAS technical support to get an official solution.
Link is OFF!
I assume you are talking about Ken's link? You should contact Ken.
Thanks, Ken, your step by step instructions worked like a charm! Thanks for sharing! Angela
Thanks, Angela-- nice to hear someone saw this! If you follow the commands I mentioned with ; wpgm, you'll also go back to the most recent program window.
Pingback: Readers’ choice 2011: The DO Loop’s 10 most popular posts - The DO Loop
Ken, many thanks! I set up the F12 key and now press it whenever I need a clean output window before a new run. Wonderful solution to a vexing problem. You might remind folks to hit "Save" after doing the "gsubmit..." Your newest fan, Roger
Yes, the step by step instructions were easy to follow, and worked perfectly. This issue was really bugging me, so I thank you very much!
I don't have 9.3 but up through 9.2.3 have used odsresults; select all;clear; assigned to a function key for similar purpose. Does this still work in 9.3?
It still "works" in that it clears the ODS results viewer, which is like a table of contents. However, it does not close the default html destination.
Does anyone know if there is a way to clear the results "tree"/TOC via issuing a command or set of commands as code written in the program editor window? (much as one can do to clear the output with Rick's suggested ods html close; ods html; sequence). Thanks.
Tor, try this combination:
odsres;clear;
ODSRES puts focus on the ODS Results window, and CLEAR...well...clears it.
Hi,
I tried Ken's step by step instructions on how to clear the Results Viewer window, but it doesn't work for me! When I click on the icon I've created for this task nothing happens... I'm running 64-bit SAS 9.3 on Windows 7 Professional (if it makes any difference). Any and all help will be greatly appreciated.
The GSUBMIT command puts statements from the Windows clipboard, or other commands that you specify, into the "submit buffer" stream for the currently active session. It's possible that the shortcut won't work if the active window isn't one that can process the command, or the active session is already busy processing something else. Also, the command has to be on the HTML results window, not the editor window. If you don't see the statements reflected in the log, it didn't work.
In the notes for GSUBMIT, there is this:
I was able to get it working with SAS 9.3 64-bit on Windows.
Thank you
I just copied and pasted the codes that Rick Wicklin gave above into my SAS file at an early point and it worked fine. Copy and paste is good and I keep things simple by renaming and modifying programs that work. That way, the codes will be there.
Thanks Rick.
Nonetheless, as simple as I am, I've been able to set a single keystroke to clear all the other windows and it seems this should be a nobrainer for the gurus at SAS.
You'll be happy to know that this problem was fixed in the 9.3M2 version of SAS. In later releases, click in the output window to activate it, and select Edit-->Clear All.
Ok, nice! I did it but I modified it a bit. I defined a function key, but instead of putting it it:
gsubmit "ods html close; ods html;"
I've put it it:
gsubmit "ods html close; ods html;"; submit
So the window is cleared and the code is launched automatically. It seems to work, but every second time (I have to kit the key twice to have this running one time). The other problem that I have is that - if I run codes that generate graphs - my working directory gets full of png files! How can this be solved?
Thanks for any help on this!
Eric.
Well, I suppose that you could delete the PNG files yourself by hooking some SAS code into the function key (or creating a new function key), but if it were me, I wouldn't worry about it unless it is causing problems. The WORK directory will get cleaned up when you exit SAS.
Thanks!
1) No the directory is not cleaned up when I exit SAS! These file are annoying (I got hundreds of them rapidly).
2) You are not answering my first point: Why do I have to launch thing always twice?
Thanks in all cases for your time!
Cheers, Eric.
1) If the WORK directory is not cleaned up upon exit, I do not know why. You can call SAS Technical Support. They might have seen this problem before and can suggest a solution.
2) I do not know why you have to hit the function key twice. I and others have offered several options that work.
Thanks for the tip! I like to clear output at the top of every script. Here's how I'm making that happen in 9.3, thanks to folks here.
ods html close;
ods html;
dm 'odsres; select all;clear;';
how can we print only the report procedure output on output window while run the entaire program?
Use the ODS SELECT statement to select only certain tables:
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/viewer.htm#a002233364.htm
I created a new key as described above which worked nicely but I also found that while in the ODS output window I could just use CTRL+E to clear and close that window in one step.
Chandra,
Thanks for the short cut, that you have given, it is working fine for me. but i have a question.
Did you create that shortcut? or is it predefined in SAS?
if you have created it, could you please let me know how to create?
Thank you for you help
Hi Rick, is there any shortcut key in SAS 9.3 for show "results viewer"?
In SAS 9.2 I used F5 F6 F7 to siwtch between enhanced editor/ log/ output, but now "results viewer" is the default output destination, I need a shortcut key to show it.
thanks a lot~~
You can ask general questions like this at the SAS Support Communities
Thanks! This was very helpful!