Previous Page | Next Page

Dictionary of ODS Language Statements

ODS SELECT Statement



Specifies output objects for ODS destinations.
Valid: anywhere
Category: ODS: Output Control
See also: ODS EXCLUDE Statement
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.

Syntax
Required Arguments
Options
Example
Using a Selection List with Multiple Procedure Steps
Conditionally Selecting Output Objects
See Also

Syntax

ODS <ODS-destination> SELECT selection(s) | ALL | NONE;


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,

    Univariate.City_Pop_90.TestsForLocation
    is the full path of the output object.
  • 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, if the full path is

    Univariate.City_Pop_90.TestsForLocation
    then the partial paths are:
    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

    "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.  [cautionend]

  • 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, if the label path is

    "The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
       
    then the partial label paths are:
    "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 .

Restriction:
See also: ODS TRACE Statement
(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.
Tip: 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.
Tip: To temporarily suspend a destination, use ODS SELECT NONE. Use ODS SELECT ALL when you want to resume sending output to the suspended destination.

Options

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. For a discussion of ODS destinations, see Understanding ODS Destinations.

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


Example


Example 1: Using a Selection List with Multiple Procedure Steps

ODS features:

ODS SELECT statement:

with label

with name

with and without PERSIST

ALL

ODS SHOW statement

ODS HTML statement:

BODY=

CONTENTS=

FRAME=

PAGE=

Other SAS features:

PROC GLM

PROC PRINT

PROC PLOT

Data Sets:

See Creating the Iron Data Set.

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.

Note:   This example uses filenames that might not be valid in all operating environments. To successfully run the example in your operating environment, you might need to change the file specifications. See ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]

This example creates and prints data sets from the parameter estimates that PROC GLM generates. This procedure is part of SAS/STAT software.


Program

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

SAS Log

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

10   ods html body='odspersist-body.htm'
11        contents='odspersist-contents.htm'
12           frame='odspersist-frame.htm'
13            page='odspersist-page.htm';
NOTE: Writing HTML Body file: odspersist-body.htm
NOTE: Writing HTML Contents file: odspersist-contents.htm
NOTE: Writing HTML Pages file: odspersist-page.htm
NOTE: Writing HTML Frames file: odspersist-frame.htm
14   ods show;
Current OVERALL select list is: ALL   [1]
15   ods select ParameterEstimates
16              "Type III Model ANOVA";
17   ods show;
Current OVERALL select list is:    [2]
1. ParameterEstimates
2. "Type III Model ANOVA"
18   proc glm data=iron;
19      model loss=fe;
20      title 'Parameter Estimates and Type III Model ANOVA';
21   run;
22   ods show;
Current OVERALL select list is:    [3]
1. ParameterEstimates
2. "Type III Model ANOVA"
23   quit;
NOTE: PROCEDURE GLM used:
      real time           x.xx seconds
      cpu time            x.xx seconds
      
24   ods show;
Current OVERALL select list is: ALL   [4]
25   proc glm data=iron;
26      model loss=fe;
27      title 'All Output Objects Selected';
28   run;
29   quit;
NOTE: PROCEDURE GLM used:
      real time           x.xx seconds
      cpu time            x.xx seconds
      
30   ods select OverallANOVA(persist) "Fit Statistics";
31   proc glm data=iron;
32      model loss=fe;
33      title 'OverallANOVA and Fitness Statistics';
34   run;
35   quit;
NOTE: PROCEDURE GLM used:
      real time           x.xx seconds
      cpu time            x.xx seconds
      
36   
37  ods show;
Current OVERALL select list is:    [5]
1. OverallANOVA(PERSIST)
38  proc glm data=iron;
39     model loss=fe;
40     title 'OverallANOVA';
41     title2 'Part of the Selection List Persists';
42  run;
43  quit;
NOTE: PROCEDURE GLM used:
      real time           x.xx seconds
      cpu time            x.xx seconds
      
44  proc print data=iron;
45     title 'The IRON Data Set';
46  run;
NOTE: PROCEDURE PRINT used:
      real time           x.xx seconds
      cpu time            x.xx seconds
      
47  ods select all;
48  proc plot data=iron;
49     plot fe*loss='*' / vpos=25 ;
50     label fe='Iron Content'
51         loss='Weight Loss';
52     title 'Plot of Iron Versus Loss';
53  run;
54  quit;

HTML Output

Contents File Produced by the ODS HTML Statement

 Note about figure

[Contents File Produced by the ODS HTML Statement]


Example 2: Conditionally Selecting Output Objects

ODS features:

ODS SELECT statement:

WHERE= option

ODS TRACE statement:

LABEL option

EXCLUDED

ODS HTML statement

Other SAS features:

PROC UNIVARIATE


Program

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

SAS Log: Trace Record

Partial SAS Log Including Trace Record

Output Excluded:
-------------
Name:       Moments
Label:      Moments
Template:   base.univariate.Moments
Path:       Univariate.Systolic.Moments
Label Path: 'The Univariate Procedure'.'Systolic'.'Moments'
-------------

Output Excluded:
-------------
Name:       BasicMeasures
Label:      Basic Measures of Location and Variability
Template:   base.univariate.Measures
Path:       Univariate.Systolic.BasicMeasures
Label Path: 'The Univariate Procedure'.'Systolic'.
          'Basic Measures of Location and Variability'
-------------

Output Excluded:
-------------
Name:       TestsForLocation
Label:      Tests For Location
Template:   base.univariate.Location
Path:       Univariate.Systolic.TestsForLocation
Label Path: 'The Univariate Procedure'.'Systolic'.
          'Tests For Location'
-------------

Output Excluded:
-------------
Name:       Quantiles
Label:      Quantiles
Template:   base.univariate.Quantiles
Path:       Univariate.Systolic.Quantiles
Label Path: 'The Univariate Procedure'.
          'Systolic'.'Quantiles'
-------------

Output Excluded:
-------------
Name:       ExtremeObs
Label:      Extreme Observations
Template:   base.univariate.ExtObs
Path:       Univariate.Systolic.ExtremeObs
Label Path: 'The Univariate Procedure'.
          'Systolic'.'Extreme Observations'
-------------
Output Added:
-------------
Name:       Moments
Label:      Moments
Template:   base.univariate.Moments
Path:       Univariate.Diastolic.Moments
Label Path: 'The Univariate Procedure'.'Diastolic'.'Moments'
-------------

Output Excluded:
-------------
Name:       BasicMeasures
Label:      Basic Measures of Location and Variability
Template:   base.univariate.Measures
Path:       Univariate.Diastolic.BasicMeasures
Label Path: 'The Univariate Procedure'.'Diastolic
       '.'Basic Measures of Location and Variability'
-------------

Output Excluded:
-------------
Name:       TestsForLocation
Label:      Tests For Location
Template:   base.univariate.Location
Path:       Univariate.Diastolic.TestsForLocation
Label Path: 'The Univariate Procedure'.'Diastolic'.
          'Tests For Location'
-------------

Output Excluded:
-------------
Name:       Quantiles
Label:      Quantiles
Template:   base.univariate.Quantiles
Path:       Univariate.Diastolic.Quantiles
Label Path: 'The Univariate Procedure'.'Diastolic'.'Quantiles'
-------------

Output Excluded:
-------------
Name:       ExtremeObs
Label:      Extreme Observations
Template:   base.univariate.ExtObs
Path:       Univariate.Diastolic.ExtremeObs
Label Path: 'The Univariate Procedure'.'Diastolic'.
'Extreme Observations'
-------------

HTML Output

[untitled graphic]


See Also

Statements:

ODS EXCLUDE Statement

ODS SHOW Statement

ODS TRACE Statement

Previous Page | Next Page | Top of Page