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