Using the Output Delivery System |
Paths and Selection |
Each output from a SAS procedure has an associated name and label. Each name is part of a name path, and each label is part of a label path. For example, PROC GLM has a table called ErrorSSCP, and the name path (fully qualified name) is GLM.Repeated.MANOVA.Model.Error.ErrorSSCP. Each level in the name path corresponds to a part of the PROC GLM hierarchy of output. Tables and graphs also have labels and label paths. For example, the PROC GLM ErrorSSCP table is labeled 'SSCP Matrix', and the label path is ’The GLM Procedure’.’Repeated Measures Analysis’.’MANOVA’.’Model’.’Error’.’SSCP Matrix’.
In order to select, exclude, or modify a table, you must first know its name (or label). You can obtain the table names in several ways:
You can obtain table names from the individual procedure chapter or from the individual procedure section of the SAS online Help system. See the "ODS Table Names" section within the "Details" section of the procedure documentation chapter.
You can use the SAS Results window to view the names of the tables created in your SAS session (see the section ODS and the SAS Results Window for more information).
You can use the ODS TRACE statement to find the names of tables created in your SAS session. The ODS TRACE statement writes identifying information to the SAS log or listing for each generated output table.
If you are working interactively with reasonably small data sets, then the ODS TRACE statement is usually the most convenient way to find the names. Specify the ODS TRACE ON statement prior to the procedure statements that create the output for which you want information. For example, the following statements write the trace record for the specific tables created in the REG procedure step:
ods trace on; proc reg; model y=x; model z=x; run; ods trace off;
By default, the trace record is written to the SAS log. The output from this step is as follows:
Output Added: ------------- Name: NObs Label: Number of Observations Template: Stat.Reg.NObs Path: Reg.MODEL1.Fit.y.NObs ------------- Output Added: ------------- Name: ANOVA Label: Analysis of Variance Template: Stat.REG.ANOVA Path: Reg.MODEL1.Fit.y.ANOVA ------------- Output Added: ------------- Name: FitStatistics Label: Fit Statistics Template: Stat.REG.FitStatistics Path: Reg.MODEL1.Fit.y.FitStatistics ------------- Output Added: ------------- Name: ParameterEstimates Label: Parameter Estimates Template: Stat.REG.ParameterEstimates Path: Reg.MODEL1.Fit.y.ParameterEstimates ------------- Output Added: ------------- Name: NObs Label: Number of Observations Template: Stat.Reg.NObs Path: Reg.MODEL2.Fit.z.NObs ------------- Output Added: ------------- Name: ANOVA Label: Analysis of Variance Template: Stat.REG.ANOVA Path: Reg.MODEL2.Fit.z.ANOVA -------------
Output Added: ------------- Name: FitStatistics Label: Fit Statistics Template: Stat.REG.FitStatistics Path: Reg.MODEL2.Fit.z.FitStatistics ------------- Output Added: ------------- Name: ParameterEstimates Label: Parameter Estimates Template: Stat.REG.ParameterEstimates Path: Reg.MODEL2.Fit.z.ParameterEstimates -------------
Alternatively, you can specify the LISTING option (ods trace on / listing;), which writes the trace record, interleaved with the procedure output, to the LISTING destination.
The trace record contains the name of each created table and its associated label, template, and fully qualified name path. The label provides a description of the table. The fully qualified name path shows the output hierarchy for the table. (An example of the hierarchy is shown in Figure 20.2. The SAS Results window displays the labels, rather than the names of objects, but the hierarchy is the same for both names and labels.) In this example, the hierarchy has a level for the REG procedure, a level for the model (MODEL1 or MODEL2), a level for the fit results, a level for the dependent variable (y or z), and a level for the table name (NObs, ANOVA, FitStatistics, ParameterEstimates).
When you work with ODS objects, you can often omit levels and instead use a partially qualified name path. A partially qualified name path consists of any part of the fully qualified name path that begins immediately after a period and continues to the end of the fully qualified name path. For example, the table Reg.Model1.Fit.y.ParameterEstimates can be referenced in any of the following ways:
ParameterEstimates |
name |
y.ParameterEstimates |
partially qualified name path |
fit.y.ParameterEstimates |
partially qualified name path |
Model1.fit.y.ParameterEstimates |
partially qualified name path |
Reg.Model1.fit.y.ParameterEstimates |
fully qualified name path |
When a procedure creates multiple tables that have the same name, as shown in the preceding trace output, you have several selection options for referring to a table. You can specify the name, a fully qualified name path, or a partially qualified name path in ODS statements such as ODS SELECT, ODS EXCLUDE, or ODS OUTPUT. You can also specify a WHERE clause. For example, you can specify any of the following statements (in addition to other possibilities) to display both tables of parameter estimates:
ods select ParameterEstimates; ods select y.ParameterEstimates z.ParameterEstimates; ods select Reg.Model1.Fit.y.ParameterEstimates Reg.Model2.Fit.z.ParameterEstimates; ods select where = (_path_ ? 'Parameter');
The first ODS SELECT statement specifies the single name, which is shared by both tables. The second statement specifies a partially qualified name path for both tables. The third statement specifies the fully qualified name path for each table. The fourth statement selects every object (table or graph) that contains the string 'Parameter' anywhere in its path.
Note that in the first three statements, selection is case insensitive. Any combination of uppercase and lowercase letters works. This is not true in the fourth statement, which uses an ordinary SAS comparison of character strings. For case insensitivity in WHERE clause selection, use the LOWCASE function as in the following example:
ods select where = (lowcase(_path_) ? 'parameter');
You can also select objects based on a WHERE clause and the label path. The following statements turn on the trace record, display a label path in addition to the name path, and select all tables that have the string 'var' in the label:
ods trace on / label; ods select where = (lowcase(_label_) ? 'var');
A subset of the trace record for PROC REG with this select list, showing just the name path and label path, is as follows:
Path: Reg.MODEL1.Fit.y.ANOVA Label Path: 'The Reg Procedure'.'MODEL1'.'Fit'.y.'Analysis of Variance' Path: Reg.MODEL2.Fit.z.ANOVA Label Path: 'The Reg Procedure'.'MODEL2'.'Fit'.z.'Analysis of Variance'
The ODS SELECT statement selects the ANOVA tables, because they have the string 'Analysis of Variance' (which when lowercased contains 'var') in their labels. WHERE clause selection is also useful for selecting all of the objects within a group or level of the path hierarchy (the group 'MODEL2' or 'Fit'). You can specify any part of the name path or label path—for example, '.z.' matches the variable z and ignores any 'z' that might be in the middle of a word, '2.F' matches model 2 fit tables and any other table that has the string '2.F' in its path, and so on.
ODS records the specified table names in its internal selection or exclusion list, and then it processes the output it receives. Note that ODS maintains an overall selection or exclusion list that pertains to all ODS destinations, and it maintains a separate selection or exclusion list for each ODS destination. The list for a specific destination provides the primary filtering step. The restrictions that you specify in the overall list are added to the destination-specific lists.
Suppose, for example, that your LISTING exclusion list (that is, the list of tables you want to exclude from the LISTING destination) contains the FitStatistics table, which you specify with the following statement:
ods listing exclude FitStatistics;
Suppose also that your overall selection list (that is, the list of tables you want to select for all destinations) contains the tables ParameterEstimates and FitStatistics, which you specify with the following statement:
ods select ParameterEstimates FitStatistics;
ODS then sends only the ParameterEstimates and FitStatistics tables to all open destinations except the LISTING destination. It sends only the ParameterEstimates table to the LISTING destination because the table FitStatistics is excluded from that destination.
Copyright © SAS Institute, Inc. All Rights Reserved.