BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
EricCai
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

8 REPLIES 8
EricCai
Calcite | Level 5

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.

ballardw
Super User

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

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

EricCai
Calcite | Level 5

Thanks, ballardw!

The following also works:

dm output 'clear';

Reeza
Super User

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';;

EricCai
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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 CLOSE;) 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
EricCai
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 11011 views
  • 8 likes
  • 5 in conversation