The SAS Output Delivery System and reporting techniques

Knowing which ODS destination is currently open

Reply
Super Contributor
Posts: 260

Knowing which ODS destination is currently open

Hi all !
I was just wondering (in fact I don't currently have the need for it, but just in case) if you can check which ODS destinations are currently open in a SAS program ? Some automatic macro-variable ? A well-hiden function ? Special kung-fu tricks from old chaolin masters ?
Whatever answer will suit me.

Thanks in advance.
Olivier

PS : sorry if it's a silly question with a very simple answer, but I have not found any for the moment.
SAS Super FREQ
Posts: 8,868

Re: Knowing which ODS destination is currently open

Olivier:
I am not aware of a super-secret macro variable, as nice as that might be. ;-)

However, one fact of ODS that may not be as well known as others is that ODS keeps track of selection and exclusion lists for all open destinations. Selection and exclusion lists are those lists of output objects that you can select for a destination. Let's say for example that you are running a PROC CONTENTS and a PROC UNIVARIATE and you want JUST the VARIABLES list from PROC CONTENTS to go LISTING and HTML, and you want BASICMEASURES to go to HTML. You can do this: [pre]
ods listing;
ods html file='foobar.html';
ods LISTING select variables;
ODS HTML select variables;

ODS HTML SHOW ;
ODS LISTING SHOW ;

proc contents data=sashelp.class;
run;

ods HTML select BasicMeasures;
ODS HTML SHOW;

proc univariate data=sashelp.class;
var height;
run;
ods html close;
ods listing close;

ODS LISTING SHOW;
ODS RTF SHOW;
ODS PDF SHOW;
ODS HTML SHOW;
[/pre]

The purpose of ODS SHOW is to show you the state of the selection/exclusion list for a ALL destinations or particular destinations. As you can see from the ERROR messages that you get after you issue ODS LISTING CLOSE; you could construct a macro that would "test" which destination was open if you needed to.

The thing is that if you get into the habit of issuing ODS LISTING CLOSE; only when you need to close the LISTING window and then ALWAYS issue an
ODS LISTING;
for every close, then when you start a program, the LISTING destination should be OPEN.

Another thing that I do, when I have multiple destinations open is to issue:
ODS _ALL_ CLOSE; (to close everything)
ODS LISTING;
in order to immediately reopen the LISTING destination.
cynthia
SAS Employee
Posts: 174

Re: Knowing which ODS destination is currently open

This is an oft-requested feature. It has been implemented in the upcoming SAS 9.2 release. Simply query SASHELP.VDEST, e.g.:
[pre]
proc print data=sashelp.vdest;run;



Obs destination style

1 LISTING Listing
2 HTML Default
3 RTF Rtf
NOTE: There were 3 observations read from the data set SASHELP.VDEST.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
[/pre]
Note that there's a Listing style named ... well ... Listing. That was added in support of ODS graphics, which is another new SAS 9.2 feature.

-- David Kelley, SAS
Super Contributor
Posts: 260

Re: Knowing which ODS destination is currently open

Thank you David for the good news. This looks very simple, easy to use, efficient.
I'm really looking forward to work on 9.2 !

Cynthia, thank you for the reminder on ODS SHOW. There was no allusion to proc Report in your example ?! I thought you ALWAYS managed to put some Report in any example on any given subject :-)

Olivier
Ask a Question
Discussion stats
  • 3 replies
  • 335 views
  • 0 likes
  • 3 in conversation