I'm working on a macro that has to suppress some of its output using
ods rtf exclude all;
Under the assumption that the user was outputting to rtf (default user behavior for us), once this piece of the macro is done, it turns output back on using
ods rtf select all;
However, there are some use cases where the user was suppressing the printout of my macro outputs. In this case, I'd like my code to determine what ods output the user had selected and return to that after the excluded portion of macro code runs. Is there a sashelp/dictionary table that contains this information? I've already looked through vstyle, voption, vallopt, vrememb and didn't see anything specific that told me which state to revert to.
I managed to find a way to get the info I needed from ods show.
proc printto log="/dest/test.txt"; run; ods show; proc printto; run; data _null_; infile "/dest/test.txt"; input ; lines=_infile_; if _n_ = 8 then do; call symputx('ODS_SHOW',_infile_); end; run; %let ODS_SHOW = %sysfunc(prxchange(s!Current OVERALL select list is: !!,1,&ODS_SHOW));
One method of doing this as you mentioned is to use the SASHELP.VDEST table. Does this work for you? Either in SQL using the Dictionary.vdest table or in the DATA step.
data temp; set sashelp.vdest; run;
Here's the table produced by printing sashelp.vdest, which I don't think is enough info for me to restore their defaults after I exclude everything.
@hartwell Sorry, I did not read closely enough. This information which is selected does not get stored in a location that can be retrieved. However, if you are interested in the selected information, you could in tandem create an ODS DOCUMENT with the selected information and replay this. See the following example.
ods rtf file="c:\temp\temp1.rtf";
/* Print selected output and create an ODS Document with the selected output */
ods select all;
ods document name=temp;
proc freq data=sashelp.class;
run;
ods select none;
proc print data=sashelp.class;
run;
ods document close;
ods rtf close;
/* Display the selected output */
proc document name=test(update);
replay;
quit;
@hartwell wrote:
Here's the table produced by printing sashelp.vdest, which I don't think is enough info for me to restore their defaults after I exclude everything.
It is enough for the code you showed since all you needed to know was the value of the DESTINATION variable to generate your two statements.
ods rtf exclude all;
ods rtf select all;
So assuming you want to first prevent output from going to the active destinations you could do something like:
data _null_;
set sashelp.vdest;
where dest ne 'OUTPUT';
call execute(catx(' ','ods',destination,'exclude all;'));
run;
Then add a similar step at the point where you want to start sending output their way again.
I think you are getting confused and thought you would need to recreate the original ODS statement that defined the destination. You would only need to do that if had run this command:
ods rtf close;
And if your question meant that someone else had closed the RTF destination before your code ran then the only way to recreate it is to be like Big Jule in Guys and Dolls and "remember where they once was."
I managed to find a way to get the info I needed from ods show.
proc printto log="/dest/test.txt"; run; ods show; proc printto; run; data _null_; infile "/dest/test.txt"; input ; lines=_infile_; if _n_ = 8 then do; call symputx('ODS_SHOW',_infile_); end; run; %let ODS_SHOW = %sysfunc(prxchange(s!Current OVERALL select list is: !!,1,&ODS_SHOW));
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.