ODS SELECT Statement

Specifies output objects for ODS destinations.
Valid in: Anywhere
Category: ODS: Output Control
Tip: You can maintain a selection list for one destination and an exclusion list for another. However, it is easier to understand the results if you maintain the same types of lists for all of the destinations to which you route output.
See: ODS EXCLUDE Statement

Syntax

Required Arguments

selection(s)
specifies output objects to add to a selection list. ODS sends the items in the selection list to all active ODS destinations. By default, ODS automatically modifies selection lists when a DATA step that uses ODS or a procedure step ends. For information about modifying these lists, see Selection and Exclusion Lists. For information about ending DATA and procedure steps, see the section on DATA Step Processing in SAS Language Reference: Concepts.
Each selection has the following form:
output-object <(PERSIST)>
output-object
specifies the output object to select.
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 your SAS program produces. You can specify an output object as one of the following:
  • 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 label path for the output object is as follows:
    "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 selection list, even if the DATA or procedure step ends, until you explicitly modify the list with one of the following:
  • any ODS EXCLUDE statement
  • ODS SELECT NONE
  • ODS SELECT ALL
  • an ODS SELECT statement that applies to the same output object but does not specify PERSIST
Requirement:You must enclose PERSIST in parentheses.
ALL
specifies that ODS send all of the output objects to the open destination.
Alias:ODS SELECT DEFAULT
Interaction:If you specify ALL without specifying a destination, ODS sets the overall list to SELECT ALL and sets all other lists to their defaults.
NONE
specifies that ODS does not send any output objects to the open destination.
Interaction:If you specify NONE and you do not specify a destination, ODS sets the overall list to SELECT NONE and sets all other lists to their defaults.
Tips:Using the NONE action is different from closing a destination. The output destination is still open, but ODS restricts the output that it sends to the destination.

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 selection list to write, where ODS-destination can be any valid ODS destination except for the OUTPUT destination.
Default:If you omit ODS-destination, ODS writes to the overall selection list.
Restriction:You cannot write to the OUTPUT destination's selection list.
Tip:To set the selection list for the Output destination to something other than the default, see the ODS OUTPUT Statement .
See:Understanding ODS Destinations for a discussion of ODS destinations.
WHERE=where-expression
selects output objects that meet a particular condition. For example, the following statement selects only output objects with the word “Histogram” in their name:
ods select 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
Subsetting variables are a special type of WHERE expression operand used by SAS to help you find common values in items. For example, this ODS SELECT statement selects only output objects with the path City_Pop_90.TestsForLocation :
ods select  / 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

Examples

Example 1: Using a Selection List with Multiple Procedure Steps

Features:
ODS SELECT statement::
with label
with name
with and without PERSIST
ALL

ODS SHOW statement

ODS HTML statement options::
BODY=
CONTENTS=
FRAME=
PAGE=
Other features:

PROC GLM

PROC PRINT

PROC PLOT

Data set: Iron

Details

This example runs the same procedures multiple times to illustrate how ODS maintains and modifies a selection list. The ODS SHOW statement writes the overall selection list to the SAS log. The example does not alter selection lists for individual destinations. The contents file that is generated by the ODS HTML statement shows which output objects are routed to both the HTML and the LISTING destinations.
This example creates and prints data sets from the parameter estimates that PROC GLM generates. This procedure is part of SAS/STAT software.

Program

ods html body='odspersist-body.htm'
        frame='odspersist-frame.htm'
     contents='odspersist-contents.htm'
         page='odspersist-page.htm';
ods show;
ods select ParameterEstimates
           "Type III Model ANOVA";
ods show;
proc glm data=iron;
   model loss=fe;
   title 'Parameter Estimates and Type III Model ANOVA';
run;
ods show;
quit;
ods show;
proc glm data=iron;
   model loss=fe;
   title 'All Output Objects Selected';
run;
quit;
ods select OverallANOVA(persist) "Fit Statistics";
proc glm data=iron;
   model loss=fe;
   title 'OverallANOVA and Fitness Statistics';
run;
quit;
ods show;
proc glm data=iron;
   model loss=fe;
   title 'OverallANOVA';
   title2 'Part of the Selection List Persists';
run;
quit;
proc print data=iron;
   title 'The IRON Data Set';
run;
ods select all;
proc plot data=iron;
   plot fe*loss='*' / vpos=25 ;
   label fe='Iron Content'
       loss='Weight Loss';
   title 'Plot of Iron Versus Loss';
run;
quit;
ods html close;

Program Description

Create HTML output.The ODS HTML creates the body, contents, frame, and page files. The output from the procedures is sent to the file odspersist-body.htm. The FRAME=, CONTENTS=, and PAGE= options create the files OdsPersist-Frame.htm, OdsPersist-Contents.htm, and OdsPersist-Page.htm, respectively. These files, together with the file OdsPersist-Body.htm, create a frame that includes a table of contents and a table of pages that link to the contents of the body file.
ods html body='odspersist-body.htm'
        frame='odspersist-frame.htm'
     contents='odspersist-contents.htm'
         page='odspersist-page.htm';
Write the overall selection list to the SAS log.The ODS SHOW statement writes to the SAS log the overall list, which is set to SELECT ALL by default. See the SAS Log.
ods show;
Specify the output objects that will be sent to the open destinations.The ODS SELECT statement determines which output objects ODS sends to the LISTING and HTML destinations. In this case, ODS sends all output objects that are named ParameterEstimates and all output objects that are labeled “Type III Model ANOVA” to the two destinations.
ods select ParameterEstimates
           "Type III Model ANOVA";
Write the modified overall selection list to the SAS log.The ODS SHOW statement writes to the SAS log the overall selection list, which now contains the two items that were specified in the ODS SELECT statement. See the SAS Log.
ods show;
Create the output objects and send the selected output objects to the open destinations. As PROC GLM sends each output object to the Output Delivery System, ODS sends the two output objects from PROC GLM that match the items in the selection list to the open destinations. See 1. in the table of contents in HTML Output. Note that it is the label of an output object, not its name, that appears in the table of contents. The label for ParameterEstimates is "Solution".
proc glm data=iron;
   model loss=fe;
   title 'Parameter Estimates and Type III Model ANOVA';
run;
Write the overall selection list to the SAS log.PROC GLM supports run-group processing. Therefore, the RUN statement does not end the procedure, and ODS does not automatically modify the selection list. See the SAS Log.
ods show;
End the GLM procedure.The QUIT statement ends the procedure. ODS removes all objects that are not specified with PERSIST from the selection list. Because this action removes all objects from the list, ODS sets the list to its default, SELECT ALL.
quit;
Write the current selection list to the SAS log.The ODS SHOW statement writes the current selection list to the SAS log. See the SAS Log.
ods show;
Create the output objects, send the selected output objects to the open destinations, and end the procedure.As PROC GLM sends each output object to the Output Delivery System, ODS sends all the output objects to the HTML and LISTING destinations. See 2. in the table of contents in HTML Output. The QUIT statement ends the procedure. Because the list uses the argument ALL, ODS does not automatically modify it when the PROC step ends.
proc glm data=iron;
   model loss=fe;
   title 'All Output Objects Selected';
run;
quit;
Modify the overall selection lists.This ODS SELECT statement modifies the overall selection list. It sends all output objects that are named OverallANOVA, and all output objects that are labeled Fit Statistics, to both the HTML and LISTING destinations. The PERSIST option specifies that OverallANOVA should remain in the selection list when ODS automatically modifies it.
ods select OverallANOVA(persist) "Fit Statistics";
Create the output objects and send the selected output objects to the open destinations.As PROC GLM sends each output object to the Output Delivery System, ODS sends the two output objects from PROC GLM that match the items in the selection list to the HTML and LISTING destinations. See 3. in the table of contents in HTML Output.
proc glm data=iron;
   model loss=fe;
   title 'OverallANOVA and Fitness Statistics';
run;
End the GLM procedure and automatically modify the selection list.When the QUIT statement ends the procedure, ODS automatically modifies the selection list. Because OverallANOVA was specified with the PERSIST option, it remains in the selection list. Because Fitness Statistics was not specified with the PERSIST option, ODS removes it from the selection list.
quit;
Write the current selection list to the SAS log.The ODS SHOW statement writes the current selection list to the SAS log. See the SAS Log.
ods show;
Create the output objects and send the selected output objects to the open destinations.As PROC GLM sends each output object to the Output Delivery System, ODS sends only the output object that is named OverallANOVA to the HTML and LISTING destinations. See 4. in the table of contents in HTML Output.
proc glm data=iron;
   model loss=fe;
   title 'OverallANOVA';
   title2 'Part of the Selection List Persists';
run;
End the GLM procedure and automatically modify the selection list.When the QUIT statement ends the procedure, ODS automatically modifies the selection list. Because OverallANOVA was specified with the PERSIST option, it remains in the selection list.
quit;
PROC PRINT does not produce any output that is named OverallANOVA.Therefore, no PROC PRINT output is sent to the ODS destinations.
proc print data=iron;
   title 'The IRON Data Set';
run;
Reset all selection lists.This ODS SELECT statement resets all selection lists to their defaults.
ods select all;
Create the plots.As PROC PLOT creates and sends each output object to the Output Delivery System, ODS sends each one to the HTML and LISTING destinations because their lists and the overall list are set to SELECT ALL (the default).
proc plot data=iron;
   plot fe*loss='*' / vpos=25 ;
   label fe='Iron Content'
       loss='Weight Loss';
   title 'Plot of Iron Versus Loss';
run;
End the PLOT procedure.The QUIT statement ends the PLOT procedure. Because the list uses the argument ALL, ODS does not automatically modify the list when the PROC step ends.
quit;
Close the HTML destination.This ODS HTML statement closes the HTML destination and all the files that are associated with it.
ods html close;

SAS Log

The ODS SHOW Statement Writes the Current Selection List to the SAS Log.
The ODS SHOW Statement Writes the Current Selection List to the SAS Log.

HTML Output

The contents file shows the output objects from each procedure that ODS sent to the open ODS destinations. You can see that no output was written to the HTML destination for PROC PRINT (because PROC PRINT did not produce anything whose name matched the name in the selection list). You can also see that the PROC PLOT output was written to the HTML destination after the ODS SELECT ALL statement was executed.
Contents File Produced by the ODS HTML Statement
Contents File Produced by the ODS HTML Statement

Example 2: Conditionally Selecting Output Objects

Features:

ODS SELECT statement option:: WHERE=

ODS TRACE statement options::
LABEL
EXCLUDED

ODS HTML statement

Other features:

PROC UNIVARIATE

Program

   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;
      title 'Systolic and Diastolic Blood Pressure';
ods trace on / label excluded; 
   ods select where=(_path_ ? "Diastolic" and  _name_='Moments') ;
   proc univariate data=BPressure;
      var Systolic Diastolic;
   run;

Program Description

Create the BPressure data set.
   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;
Add a title.
      title 'Systolic and Diastolic Blood Pressure';
Specify that SAS write the trace record to the SAS log.This ODS TRACE statement writes the trace record to the SAS log. The LABEL option includes label paths in the trace record. The EXCLUDED option includes information about output objects that SAS excludes from the output destination.
ods trace on / label excluded; 
Select output objects.The ODS SELECT statement with the WHERE = option specified selects output objects that are named 'Moments' and that have 'Diastolic' in the pathname.
   ods select where=(_path_ ? "Diastolic" and  _name_='Moments') ;
Create the output objects and send the selected output objects to the open destination.As PROC UNIVARIATE sends each output object to the Output Delivery System, ODS sends the output object from PROC UNIVARIATE that matches the items in the selection list to the open destination.
   proc univariate data=BPressure;
      var Systolic Diastolic;
   run;

SAS Log: Trace Record

SAS Log Including Trace Record
SAS Log Including Trace Record

HTML Output

HTML Output