Analyze a data set with a statistical procedure. Save results from the analyses in data sets created from ODS output objects. Concisely summarize specific results in a report.
Analysis of Fitness Data Set Forward Selection of Predictors of Oxygen Consumption ----------------------------------------------- ----------- --------------------------------------------------- | F Partial Model | |Step Intercept runtime age runpulse weight maxpulse Value Pr > F R-Square R-Square C(p) | |---------------------------------------------- ----------- ------------------------------------------------- | | 1| 82.422| -3.310| NS| NS| NS| NS| 84.01| 0.00| 0.74| 0.74| 13.52 | |----+----------+--------+--------+--------+--- -----+----- ----+-------+------+---------+---------+--------- | | 2| 88.462| -3.203| -0.150| NS| NS| NS| 45.38| 0.00| 0.02| 0.76| 12.22 | |----+----------+--------+--------+--------+--- -----+----- ----+-------+------+---------+---------+--------- | | 3| 111.718| -2.825| -0.256| -0.130| NS| NS| 38.64| 0.00| 0.05| 0.81| 6.83 | |----+----------+--------+--------+--------+--- -----+----- ----+-------+------+---------+---------+--------- | | 4| 98.148| -2.767| -0.197| -0.348| NS| 0.270| 33.33| 0.00| 0.03| 0.84| 4.77 | |----+----------+--------+--------+--------+--- -----+----- ----+-------+------+---------+---------+--------- | | 5| 102.204| -2.682| -0.219| -0.373| -0.072| 0.304| 27.90| 0.00| 0.01| 0 .85| 5.00 | |---------------------------------------------- ----------- ------------------------------------------------- | | Number of Observations Read=31 | | Number of Observations Used=31 | | Number of Observations with Missing Values=0 | | | | * NS=Not Selected | ----------------------------------------------- ----------- --------------------------------------------------- |
Data Set | FITNESS |
Featured Step and Statement | ODS statement PROC REPORT |
Featured Step Statements and Options | ODS OUTPUT statement for saving output objects from PROC REG
PROC REPORT
|
Additional Features | PROC TRANSPOSE
Merging data sets in the DATA step PICTURE formats CALL SYMPUT and macro variables |
A Closer Look | Saving Results in Data Sets Created from ODS Output Objects vs. Saving Results in Procedure Output Data Sets
Designing Reports That Use Either Data Sets Created from ODS Output Objects or Procedure Output Data Sets Working with Data Sets Created from ODS Output Objects Doing More with Data Sets Created from ODS Output Objects |
The output from an analysis can take up several pages. Features of interest to you might be in different locations of the standard output, and you might want to consolidate those results in your own presentation format. You can do this by saving in data sets the specific ODS output objects produced by the analysis. You can then use DATA steps and procedures to select the results of interest and shape the data for presentation in a style that meets your requirements.
This example saves ODS output objects produced by a PROC REG analysis. DATA steps, procedures, and macro language features process the output data sets to summarize specific results of the analysis in a concise report.
This example runs PROC REG on the SASUSER.FITNESS data set and applies the forward selection technique. Each observation in SASUSER.FITNESS contains the measurements on one study participant. The actual oxygen consumption during exercise is measured, as well as several postulated predictors of oxygen consumption. The goal is to find a model by using a forward selection technique that adequately predicts oxygen consumption.
Note that this example analyzes a data set that is provided with Base SAS and assumes that you have stored the data set in the SASUSER directory. Appendix A includes code to create the data set as well.
A Closer Look |
Some SAS procedures produce output data sets, whereas others do not. The report shown in Example 4.2 was created by manipulating output data sets created by statements and options available in PROC MEANS and PROC FREQ.
Procedure output data sets save components of an analysis, but not necessarily all components of an analysis can be saved in procedure output data sets. When features of the output cannot be saved in a procedure output data set, you can usually save that information in data sets created from ODS output objects.
The results in this example were saved in data sets created from ODS output objects. PROC REG does not have the output options or statements to save the step selection results that are required for the report. For example, the PROC REG OUTEST= option saves the parameter estimates for only the final model. Therefore, the only way to produce this example’s report is to save the step selection results in data sets created from ODS output objects.
When writing your programs, you might need to evaluate whether to save results with procedure OUTPUT statements and options or in data sets created from ODS output objects. Review the layout of the observations in the procedure output data sets and in the data sets created from ODS output objects to determine which method makes it most efficient to process the data to meet your reporting requirements. You might even find that combining both methods works best.
You might find that it’s an iterative process for you to customize a report that is based on information extracted from data sets created from ODS output objects or from data sets created from procedure statements and options. Before finalizing your report step, you will need to know the ODS output objects and procedure output data sets that your analysis procedure can produce.
Until you repeatedly use the same ODS output objects and procedure output data sets, you will probably have to submit your procedure step and examine the contents of the output data sets. Then you can write ODS statements and procedure features that save what you need. Following that, you might need to use other procedures to reshape the data sets and save specific information. These types of preparatory steps were required in the main program of this example. Finally, you can write the code for your customized report. This example used PROC REPORT, and you can use this or any other SAS reporting procedure or DATA step to produce your report.
SAS data sets are one of the several SAS and third-party formatted destinations that ODS can create. Just as you can send output objects from a procedure to a destination such as LISTING or HTML, you can send the same objects to a SAS data set.
When you want to save ODS output objects in data sets, you need to know the names of the objects that the procedure produces. Several of these names are documented in SAS 9.1 Output Delivery System: User’s Guide. A second way to determine the names is to submit the procedure and look up the names of the output objects in the Results window. Finally, a third way you can determine them is to issue the ODS TRACE ON statement before you execute the procedure. This statement writes a trace record to the SAS log that includes the path, the label, and other information about each of the output objects. To terminate the trace record, submit ODS TRACE OFF.
The following code lists in the SAS log the output objects produced by the PROC REG step in the main program.
ods trace on; proc reg data=sasuser.fitness; model oxygen=age weight runtime runpulse rstpulse maxpulse / selection=forward; quit; ods trace off;
The ODS TRACE ON statement writes the information to the SAS log. Figure 4.3 shows the results of the above step that includes this statement. Notice that there are four types of output objects produced by this step. There are five occurrences each of two of the output objects: ANOVA and SelParmEst. Each occurrence corresponds to one of the five steps of the forward selection analysis. PATH shows a reference to the step for those two output objects.
Output Added: ------------- Name: NObs Label: Number of Observations Template: Stat.Reg.NObs Path: Reg.MODEL1.SelectionMethod.oxygen.NObs ------------- Output Added: ------------- Name: ANOVA Label: ANOVA Template: Stat.REG.ANOVA Path: Reg.MODEL1.SelectionMethod.oxygen.Step1.ANOVA ------------- Output Added: ------------- Name: SelParmEst Label: Parameter Estimates Template: Stat.REG.SelParmEst Path: Reg.MODEL1.SelectionMethod.oxygen.Step1.SelParmEst ------------- Output Added: ------------- Name: ANOVA Label: ANOVA Template: Stat.REG.ANOVA Path: Reg.MODEL1.SelectionMethod.oxygen.Step2.ANOVA ------------- Output Added: ------------- Name: SelParmEst Label: Parameter Estimates Template: Stat.REG.SelParmEst Path: Reg.MODEL1.SelectionMethod.oxygen.Step2.SelParmEst ------------- Output Added: ------------- Name: ANOVA Label: ANOVA Template: Stat.REG.ANOVA Path: Reg.MODEL1.SelectionMethod.oxygen.Step3.ANOVA ------------- Output Added: ------------- Name: SelParmEst Label: Parameter Estimates Template: Stat.REG.SelParmEst Path: Reg.MODEL1.SelectionMethod.oxygen.Step3.SelParmEst ------------- Output Added: ------------- Name: ANOVA Label: ANOVA Template: Stat.REG.ANOVA Path: Reg.MODEL1.SelectionMethod.oxygen.Step4.ANOVA ------------- Output Added: ------------- Name: SelParmEst Label: Parameter Estimates Template: Stat.REG.SelParmEst Path: Reg.MODEL1.SelectionMethod.oxygen.Step4.SelParmEst ------------- Output Added: ------------- Name: ANOVA Label: ANOVA Template: Stat.REG.ANOVA Path: Reg.MODEL1.SelectionMethod.oxygen.Step5.ANOVA ------------- Output Added: ------------- Name: SelParmEst Label: Parameter Estimates Template: Stat.REG.SelParmEst Path: Reg.MODEL1.SelectionMethod.oxygen.Step5.SelParmEst ------------- Output Added: ------------- Name: SelectionSummary Label: Selection Summary Template: Stat.REG.SelectionSummary Path: Reg.MODEL1.SelectionMethod.oxygen.SelectionSummary ------------- |
The main example references the output objects by the value assigned to “Name:” in the above display. The syntax of the ODS OUTPUT statement requires that you follow the reference to your output object with an equal sign and the name you want to assign to the data set produced by the ODS output object. The example shows that you can reference multiple output objects on the ODS OUTPUT statement and produce a data set for each of those output objects.
The ANOVA and SelParmEst objects contain results from each step of the forward selection process. Five observations corresponding to the five forward selection steps are saved in each of the two data sets. The variable STEP saved in the data sets created from the ODS output objects identifies the step in the process.
There are multiple ways to reference your output object in the ODS OUTPUT statement, including the following specifications:
□ | the full path |
□ | a partial path |
□ | the label in quotes |
□ | the name in quotes |
You can create multiple copies of an object by referencing it multiple times in an ODS OUTPUT statement. For details on specifying the ODS OUTPUT statement, refer to SAS 9.1 Output Delivery System: User’s Guide and online information.
If you intend to incorporate output objects in your customized reports, you might want to explore the additional features of the ODS OUTPUT statement and other features of the ODS facility. Tasks that you can accomplish when working with data sets created from ODS output objects include the following:
Saving and/or displaying specific output objects. See the ODS SELECT and ODS EXCLUDE statements. These statements control display of output objects.
Creating data sets from ODS output objects without creating a standard report. See ODS LISTING CLOSE. This statement closes the default output destination. Many procedures allow you to suppress output with a NOPRINT option, but if you do that along with an ODS OUTPUT statement, no ODS output objects are created. You must create an output object in order for its associated ODS output data set to be produced. An option such as NOPRINT suppresses the creation of ODS output objects while ODS LISTING CLOSE does not.
Creating one data set for an ODS output object from multiple executions of the same procedure and specifying the ODS OUTPUT statement once rather than before each execution of the procedure. See the PERSIST= option on the ODS OUTPUT statement. The following code creates one data set, MULTMODELS, that contains the results from both PROC REG steps. The ODS OUTPUT CLOSE statement terminates the request to save ANOVA output objects in the MULTMODELS data set. If you did not issue this statement, any subsequent executions of PROC REG or other procedures that produce an ANOVA output object would cause the ANOVA results to be added to the MULTMODELS data set.
ods output anova(persist=proc)=multmodels; proc reg data=sasuser.fitness; model oxygen=age; quit; proc reg data=sasuser.fitness; model oxygen=runtime; quit; ods output close;
Creating multiple data sets for an output object from one execution of a procedure that is doing BY-group analyses. See the MATCH_ALL option on the ODS OUTPUT statement. The three values for GROUP in SASUSER.FITNESS cause the following code to create three data sets, one for each value of group: MULTSETS, MULTSETS1, and MULTSETS2.
proc sort data=sasuser.fitness out=fitsorted; by group; run; ods output anova(match_all)=multsets; proc reg data=fitsorted; by group; model oxygen=age; quit;
The MATCH_ALL option has an optional parameter that specifies the name of a macro variable that retains the names of the data sets created from the multiple output objects. This macro variable can be useful in referencing the multiple data sets in subsequent DATA steps and in saving you some typing. For example, the following code saves the data set names in the MULTSETNAMES macro variable. The DATA step concatenates the three data sets.
ods output anova(match_all=multsetsnames)= multsets; proc sort data=sasuser.fitness out=fitsorted; by group; run; proc reg data=fit; by group; model oxygen=age; quit; data combined; set &multsetsnames; run;
Creating multiple data sets for an output object from multiple executions of the same procedure, and specifying the ODS OUTPUT statement once rather than before each execution of the procedure. See the MATCH_ALL option and the PERSIST= option on the ODS OUTPUT statement. This task combines the features of both the MATCH_ALL option and the PERSIST= options in the programs described previously in this section.
The following code creates four data sets, MULTRUN, MULTRUN1, MULTRUN2, and MULTRUN3. Each execution of PROC REG produces a data set from the ANOVA ODS output object, although only one ODS OUTPUT statement designated this instruction. As discussed previously in the section that describes the PERSIST= option, this program also requires an ODS OUTPUT CLOSE statement to terminate the request to save ANOVA output objects in a data set.
ods output anova (match_all persist=proc)= multrun; proc reg data=sasuser.fitness; model oxygen=age; quit; proc reg data=sasuser.fitness; model oxygen=runpulse; quit; proc reg data=sasuser.fitness; model oxygen=rstpulse; quit; proc reg data=sasuser.fitness; model oxygen=maxpulse; quit; ods output close;
MERGE statement syntax, usage information, and additional examples. See “MERGE Statement” in the “Statements” section of SAS 9.1 Language Reference: Dictionary.
ODS concepts. See “Output Delivery System” in “SAS Output” in the “SAS System Concepts” section of SAS 9.1 Language Reference: Concepts, and SAS 9.1 Output Delivery System: User’s Guide.
ODS OUTPUT statement syntax, usage information, and additional examples. See “ODS OUTPUT Statement” in the “Dictionary of ODS Language Statements” section of SAS 9.1 Output Delivery System: User’s Guide.
ODS TRACE statement syntax, usage information, and additional examples. See “ODS TRACE Statement” in the “Dictionary of ODS Language Statements” section of SAS 9.1 Output Delivery System: User’s Guide.
PROC FORMAT reference, usage information, and additional examples. See “The FORMAT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.
PROC REG reference, usage information, and additional examples. See “The REG Procedure” in SAS/STAT 9.1 User’s Guide.
PROC TRANSPOSE reference, usage information, and additional examples. See “The TRANSPOSE Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.
SAS Macro Programming. In SAS 9.1 Macro Language: Reference, see “Macro Variables” in the “Understanding and Using the Macro Facility” section, “Using SAS Language Functions in the DATA Step and Macro Facility” in the “Interfaces with the Macro Facility” section, and “Macro Language Dictionary.”
3.17.175.21