The SAS Output Delivery System and reporting techniques

ODS LISTING CLOSE does not clear list file or output window

Accepted Solution Solved
Reply
Contributor
Posts: 40
Accepted Solution

ODS LISTING CLOSE does not clear list file or output window

Hi Everyone,

This question follows up on the answer given in this discussion by Chevell@sas.

Chevell's code works to clear the HTML output in the Results Viewer, but it does not clear my list file.  New output simply adds to the existing output in the output window.

In fact, the code

ODS LISTING CLOSE;

ODS LISTING;

does not seem to do anything.

Is there any code that clears the output wiondow automatically and refreshes the output window and the list file with new output?  (I'm using SAS 9.3.)

As an example, attached is the script that I'm working with. 

Thanks.

Attachment

Accepted Solutions
Solution
‎01-02-2013 12:42 PM
Super User
Posts: 11,139

Re: ODS LISTING CLOSE does not clear list file or output window

dm "output;clear"; should clear the OUTPUT window.

Any output directed to the listing destination should appear in the output window afterwards.

View solution in original post


All Replies
PROC Star
Posts: 7,437

Re: ODS LISTING CLOSE does not clear list file or output window

: I think that the steps recommended in the following note might do what you want:

43911 - Clearing the Results window in SAS® 9.3 does not clear the ODS HTML file that is open by def...

Contributor
Posts: 40

Re: ODS LISTING CLOSE does not clear list file or output window

Hi Art,

Thanks for the quick reply, but I'm trying to clear the Output window.  I've already successfully cleared the Results window with

ODS HTML CLOSE;

ODS HTML;

I'm talking about the list file. 

If you run my code, and then run it again, you'll see that the Results window is refreshed, but the Output window is not - the same output is printed twice.  I want a code that clears the previous output in the Output window and then print the new output.

Do you see my problem now?

Thanks.

Solution
‎01-02-2013 12:42 PM
Super User
Posts: 11,139

Re: ODS LISTING CLOSE does not clear list file or output window

dm "output;clear"; should clear the OUTPUT window.

Any output directed to the listing destination should appear in the output window afterwards.

Contributor
Posts: 40

Re: ODS LISTING CLOSE does not clear list file or output window

Thanks, ballardw!

The following also works:

dm output 'clear';

Super User
Posts: 19,180

Re: ODS LISTING CLOSE does not clear list file or output window

I think this will work instead, at least it does for me on SAS 9.2

dm 'odsresults; clear';;

proc means data=sashelp.class;

run;

proc freq data=sashelp.class;

run;

dm 'odsresults; clear';;

Contributor
Posts: 40

Re: ODS LISTING CLOSE does not clear list file or output window

Hi Reeza,

Including the line

dm 'odsresults; clear';;

at the beginning and the end was ineffective, because it erased the output completely and no new output was printed.  However, it worked perfectly when I deleted the line at the end.  Thus, when it was included at the beginning only, it worked.

Thanks.

SAS Super FREQ
Posts: 8,820

Re: ODS LISTING CLOSE does not clear list file or output window

Hi:

  At the top of your file, you have some "housekeeping" code:

** DM commands are used to clear the log and position the DM tab to the output window;

dm log 'clear' output;

     

** close any open ODS destination file for the HTML  destination;

ods html close;

    

** reopen a new cumulative HTML file;
ods html;

    

** CLOSE the LISTING/OUTPUT file -- but ONLY CLOSE -- does not clear;

ods listing close;

   

** reopen the LISTING/OUTPUT file -- still does not clear;
ods listing;

I have annotated your code with comments to show you what each of those statements is doing. None of those statements will CLEAR the output window (LISTING window). You CLEAR the log window at the top...the statement DM LOG 'CLEAR' OUTPUT does these 3 things:

1) DM LOG = send Display Manager control to the LOG window

2) 'CLEAR' = issue the CLEAR command on the LOG contents

3) OUTPUT = send Display Manager control to and position the OUTPUT window in the foreground, as the active window

Chevell's solution to that earlier post did NOT clear the LISTING/OUTPUT window -- it merely closed the LISTING destination so that nothing from the "ODS" sandwich would go to LISTING, but would instead only go to the HTML destination, as surfaced in the Results Viewer. In your code, you open the LISTING destination and the HTML destination. So essentially any code you run will go to 2 places -- the open HTML destination (which will be surfaced in the Results Viewer) and the open LISTING destination (which is surfaced in the OUTPUT window).

In your post, you asked the following questions:

"Is there any code that clears the output wiondow automatically and refreshes the output window and the list file with new output?  (I'm using SAS 9.3.)"

But let me break the answer down:

1) Is there any code that clears the output window automatically -- yes...this command will clear the log and clear the output window:

dm 'cle log; cle out;';

  

2) Is there any code that refreshes the output window and the list file WITH NEW OUTPUT????

Not sure what you mean by this....you have to delete the output from the previous run using the above commands. Then you run code, YOUR code to fill up the output window and the log again. The only code to "fill up" or "refresh" the output window with NEW output is YOUR code. Also, your references to "output window" and "list file" is confusing. In SAS Display Manager, you have 4 possible windows:

1) Editor  (window where you write code),

2) Log (window where you see the SAS log and compiler messages from running your code),

3) Output (or output window or LISTING window - -where you see the PLAIN text -- or LISTING output displayed)

4) If you have ODS results, the Results viewer window will be where ODS results, such as the automatic HTML output appears. There is no "automatic" way to clear this file. All you can do is CLOSE it (with ODS HTML CLOSESmiley Wink and then reopen a new file, which will cause SAS to start a new HTML file.

When I hear "output window", I automatically think of the place where LISTING output is displayed -- the OUTPUT window tab in Display Manager. When I hear "list file", I think you are referring to the same window as the "output window" -- so your question about how to refresh "the output window and the list file"  doesn't make sense. In my experience, the output window and the "list" file window are the same window. ODS results, whether ODS HTML, ODS RTF, or ODS PDF all get displayed in the Results Viewer window. Please see the attached screenshot for more information about the various windows and how to "clear" them.

As far as "refreshing" any of the SAS windows, you do the refreshing when you run code. Every time you run a job, output gets added to the LOG and the OUTPUT window, if the LISTING destination is open. So, generally, the pattern when running programs is to clear the log and listing windows before running or rerunning code. Closing the LISTING destination doesn't clear the Output window -- it just stops output from going there.  This pattern of working has to be changed a bit if you are using SAS 9.3 or explicit ODS statements (such as you show in your code). Every time you run your code, you will collect output in 2 places -- in the Output window and in the Results Viewer. The Output Window will keep accumulating output until you explicitly delete the output from prior runs. The screenshot shows the DM command to clear the LOT and the OUTPUT window. There is no automatic way to "clear" the Result Viewer, except to close the open ODS destinations and reissue a command to open a destination file. Remember that when you use ODS, you are creating operating system files for the collection of output.

Refer to this paper for a more complete explanation of the SAS Display Manager behavior and how to take "full control" of ODS output:

  http://support.sas.com/resources/papers/proceedings12/250-2012.pdf

Refer to this paper for a more complete explanation of SAS Display Manager commands:

http://support.sas.com/resources/papers/proceedings12/151-2012.pdf

 

cynthia


DM_windows_about.png
Contributor
Posts: 40

Re: ODS LISTING CLOSE does not clear list file or output window

Hi Cynthia,

I'm sorry for not noticing your very thoughtful and detailed reply until now.  Thank you so much for taking the time to explain all of this to me and others.  There is still much for me to learn about these fundamentals of SAS, and I really appreciate all of your help!

Eric

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 4427 views
  • 7 likes
  • 5 in conversation