BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hartwell
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
hartwell
Fluorite | Level 6

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

View solution in original post

5 REPLIES 5
Chevell_sas
SAS Employee

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;

 

hartwell
Fluorite | Level 6

hartwell_0-1733343520990.png

 

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.

Chevell_sas
SAS Employee

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

Tom
Super User Tom
Super User

@hartwell wrote:

hartwell_0-1733343520990.png

 

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."

hartwell
Fluorite | Level 6

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

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 433 views
  • 1 like
  • 3 in conversation