ODS EXCLUDE Statement

Specifies output objects to exclude from ODS destinations.
Valid in: Anywhere
Category: ODS: Output Control

Syntax

ODS <ODS-destination> EXCLUDE exclusion(s) | ALL | NONE;

Required Arguments

exclusion(s)
specifies one or more output objects to add to an exclusion list.
By default, ODS automatically modifies exclusion lists at the end of a DATA step that uses ODS, or at the end of a procedure step. For information about modifying these lists, see Selection and Exclusion Lists .
Each exclusion has the following form:
output-object <(PERSIST)>
output-object
specifies one or more output objects to exclude. To specify an output object, you need to know which output objects your SAS program produces. The ODS TRACE statement writes to the SAS log a trace record that includes the path, the label, and other information about each output object that is produced. You can specify an output object in any of the following ways:
  • a full path. For example, the following is the full path of the output object:
    Univariate.City_Pop_90.TestsForLocation
  • a partial path. A partial path consists of any part of the full path that begins immediately after a period (.) and continues to the end of the full path. For example, suppose the full path is the following:
    Univariate.City_Pop_90.TestsForLocation
    Then the partial paths are as follows:
    City_Pop_90.TestsForLocation
    TestsForLocation
  • a label that is enclosed by quotation marks.
    For example:
    "The UNIVARIATE Procedure"
  • a label path. For example, the following is the label path for the output object:
    "The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
    Note: The trace record shows the label path only if you specify the LABEL option in the ODS TRACE statement.
  • a partial label path. A partial label path consists of any part of the label that begins immediately after a period (.) and continues to the end of the label. For example, suppose the label path is the following:
     "The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
       
    Then the partial label paths are as follows:
    "CityPop_90"."Tests For Location" 
    "Tests For Location"
  • a mixture of labels and paths.
  • any of the partial path specifications, followed by a pound sign (#) and a number. For example, TestsForLocation#3 refers to the third output object that is named TestsForLocation.
(PERSIST)
keeps the output-object that precedes the PERSIST option in the exclusion list until you explicitly modify the list with any of the following ODS statements:
  • any ODS SELECT statement
  • ODS EXCLUDE NONE
  • ODS EXCLUDE ALL
  • an ODS EXCLUDE statement that applies to the same output object but does not specify PERSIST
This action is true even if the DATA or procedure step ends.
Requirement:You must enclose PERSIST in parentheses.
ALL
specifies that ODS does not send any output objects to the open destination.
Alias:ODS EXCLUDE DEFAULT
Interaction:If you specify ALL without specifying a destination, ODS sets the overall list to EXCLUDE ALL and sets all other lists to their defaults.
Tips:Using ODS EXCLUDE ALL is different from closing a destination. The destination remains open, but no output objects are sent to it.

To temporarily suspend a destination, use ODS SELECT NONE. Use ODS SELECT ALL when you want to resume sending output to the suspended destination.

NONE
specifies that ODS send all of the output objects to the open destination.
Interaction:If you specify the NONE argument without specifying a destination, ODS sets the overall list to EXCLUDE NONE and sets all other lists to their defaults.
Tips:ODS EXCLUDE NONE has the same effect as ODS SELECT ALL.

To temporarily suspend a destination, use ODS SELECT NONE. Use ODS SELECT ALL when you want to resume sending output to the suspended destination.

Optional Arguments

NOWARN
suppresses the warning that an output object was requested but not created.
ODS-destination
specifies to which ODS destination's exclusion list to write, where ODS-destination can be any valid ODS destination. For a discussion of ODS destinations, see Understanding ODS Destinations.
Default:If you omit ODS-destination, ODS writes to the overall exclusion list.
Tip:To set the exclusion list for the output destination to something other than the default, use the ODS OUTPUT Statement .
WHERE=where-expression
excludes output objects that meet a particular condition. For example, the following statement excludes only output objects with the word “Histogram” in their name:
ods exclude where=(_name_ ?  'Histogram');
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and operands. where-expression has this form:
(subsetting-variable <comparison-operator where-expression-n> )
subsetting-variable
is a special type of WHERE expression operand used by SAS to help you find common values in items. For example, this EXCLUDE statement excludes only output objects with the path City_Pop_90.TestsForLocation :
ods exclude / where=(_path_ = 'City_Pop_90.TestsForLocation' );
subsetting-variable is one of the following:
_LABEL_
is the label of the output object.
_LABELPATH_
is the label path of the output object.
_NAME_
is the name of the output object.
_PATH_
is the full or partial path of the output object.
operator
compares a variable with a value or with another variable. operator can be AND, OR NOT, OR, AND NOT, or a comparison operator.
The following table lists some comparison operators:
Examples of Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values

Details

You can maintain a selection list for one destination and an exclusion list for another. However, the results are less complicated if you maintain the same types of lists for all the destinations to which you route output.

Example: Conditionally Excluding Output Objects and Sending Them to Different Output Destinations

Features:

ODS EXCLUDE statement:: Options: ODS-Destination, WHERE=

ODS HTML statement options::
CONTENTS=
FRAME=
PAGE=
TEXT=
ODS PDF statement options::
TEXT=
STARTPAGE=
Other features:

PROC UNIVARIATE

Program

options nodate;  
   data BPressure;
      length PatientID $2;
      input PatientID $ Systolic Diastolic @@;
      datalines;
   CK 120 50  SS 96  60 FR 100 70
   CP 120 75  BL 140 90 ES 120 70
   CP 165 110 JI 110 40 MC 119 66
   FC 125 76  RW 133 60 KD 108 54
   DS 110 50  JW 130 80 BH 120 65
   JW 134 80  SB 118 76 NS 122 78
   GS 122 70  AB 122 78 EC 112 62
   HH 122 82
   ;
   run;
  ods html text='Systolic Blood Pressure' file='Systolic-body.html' 
           frame='Systolic-frame.htm'
           contents='Systolic-contents.htm'
           page='Systolic-page.htm';
ods pdf file='Diastolic.pdf' text='Diastolic Blood Pressure' startpage=no;
   
ods html exclude where=(_path_ ? "Diastolic" ) ;
ods pdf exclude where=(_path_ ? "Systolic" ) ;
   proc univariate data=BPressure;
      var Systolic Diastolic;
   run;
ods html close;
ods pdf close;

Program Description

Create the BPressure data set.
options nodate;  
   data BPressure;
      length PatientID $2;
      input PatientID $ Systolic Diastolic @@;
      datalines;
   CK 120 50  SS 96  60 FR 100 70
   CP 120 75  BL 140 90 ES 120 70
   CP 165 110 JI 110 40 MC 119 66
   FC 125 76  RW 133 60 KD 108 54
   DS 110 50  JW 130 80 BH 120 65
   JW 134 80  SB 118 76 NS 122 78
   GS 122 70  AB 122 78 EC 112 62
   HH 122 82
   ;
   run;
Create HTML output and add text.
  ods html text='Systolic Blood Pressure' file='Systolic-body.html' 
           frame='Systolic-frame.htm'
           contents='Systolic-contents.htm'
           page='Systolic-page.htm';
Create PDF output and add text.
ods pdf file='Diastolic.pdf' text='Diastolic Blood Pressure' startpage=no;
   
Exclude output objects from different output destinations.The first ODS EXCLUDE statement excludes from the HTML destination output objects that have 'Diastolic' in the pathname. The second ODS EXCLUDE statement excludes from the PDF destination output objects that have 'Systolic' in the pathname.
ods html exclude where=(_path_ ? "Diastolic" ) ;
ods pdf exclude where=(_path_ ? "Systolic" ) ;
Create the output objects.As PROC UNIVARIATE sends each output object to the Output Delivery System, ODS does not send the output objects from PROC UNIVARIATE that match the items in the exclusion list to the open destinations.
   proc univariate data=BPressure;
      var Systolic Diastolic;
   run;
Close the HTML destination.The ODS HTML CLOSE statement closes the HTML destination and all the files that are associated with it. If you do not close the destination, then you will not be able to view the HTML file specified by the FRAME attribute until you close your SAS session.
ods html close;
Close the PDF destination.This ODS PDF statement closes the PDF destination and all the files that are associated with it.
ods pdf close;

Output

Partial HTML Output with Systolic Output Objects
HTML Output with Systolic Output Objects
Partial PDF Output with Diastolic Output Objects
PDF Output with Diastolic Output Objects