I have a macro that requires ods listing to be on to produce results, however, I don't usually run SAS with ods listing b/c I'm just creating tables or sending the output to Excel. What I need to do is check the status of ods listing, turn it on if necessary and return it to the original state once the macro is finished. Thank you.
I do not believe there's a way to check the "existing" open/close status of the LISTING destination. This might be a question for Tech Support. ODS LISTING is -always- on when you start an interactive session or start a batch job....so unless you have explicitly issued an ODS _ALL_ CLOSE; or ODS LISTING CLOSE; (or put those statements in an AUTOEXEC program), you can generally be certain that the LISTING destination is on. One best practice that we recommend in our classes is to close the LISTING destination if you are creating other ODS output, but then to issue "housekeeping statements" at the end of every program to turn ODS LISTING back on:
ps..TEXT or LISTING output is turned OFF by default for SAS Enterprise Guide. That is the one exception to the above rule.
why not just leave it to the routine that is calling your macro
As "listing" is a prerequisite of your macro, it's not much different than requiring a parameter to be defined. The environment calling your macro will/should know whether the status of the listing destination is important.