Chapter Contents |
Previous |
Next |
Using the Output Delivery System |
Consider the following population growth trends. The population of the United States from 1790 to 1970 is fit to linear and quadratic functions of time. Note that the quadratic term, YearSq, is created in the DATA step; this is done since polynomial effects such as Year*Year cannot be specified in the MODEL statement in PROC REG. The data are as follows:
title1 'Concatenating Two Tables into One Data Set'; title2 'US Population Study'; data USPopulation; input Population @@; retain Year 1780; Year=Year+10; YearSq=Year*Year; Population=Population/1000; datalines; 3929 5308 7239 9638 12866 17069 23191 31443 39818 50155 62947 75994 91972 105710 122775 131669 151325 179323 203211 ;
In the following statements, the REG procedure is invoked and the ODS statement requests that a data set be created to contain the COVB matrix (the covariance matrix of the estimates).
The ODS statement uses the MATCH_ALL= and PERSIST= options. The effect of these options is to create a separate data set for each COVB matrix encountered in the entire procedure step.
proc reg data=USPopulation; ods output covb(match_all=Bname /* correct */ persist=run)=Bmatrix; var YearSq; model Population=Year / covb ; run;
The MODEL statement defines the regression model, and the COVB matrix is requested. The RUN statement executes the REG procedure and the model is fit, producing a covariance matrix of the estimates with 2 rows and 2 columns.
Output 15.9.1: Regression Results for the Model Population=Year
|
|
add YearSq; print; run;
The results of the regression are displayed in Output 15.9.3.
Output 15.9.3: Regression Results for the Model Population=Year YearSq
|
|
When you specify MATCH_ALL=name, a macro variable called name is created that contains the names of all the generated data sets. Thus, in this example, ODS creates two data sets (one for each model fit in the PROC REG run) and the macro variable Bname is created to contain the names of the two data sets.
The PERSIST=RUN option maintains the ODS selection list across RUN statements for procedures that support run-group processing. If the PERSIST=RUN option is omitted, the selection list is cleared when the RUN statement is encountered and only the first COVB matrix is selected. Because the PERSIST=RUN option is specified, the selection list remains in effect throughout the REG procedure step. This ensures that each of the COVB matrices is selected and output.
The first output data set has the specified name BMatrix. Subsequent data set names are automatically created by appending the numerals 1, 2, 3, ... , as needed. In this case, the names of the data sets are BMatrix and BMatrix1. The names are contained in the macro variable Bname.
The result of the ODS OUTPUT statement is displayed with the following statements. The SET &BName statement reads observations from all data sets listed by the macro variable Bname. The variable Bname contains the two values (BMatrix and BMatrix1). Thus, the SET statement reads observations from these two data sets. Note that, when you refer to a macro variable, an ampersand (&) always precedes a macro variable name but is not part of the name.
data new2; title 'The COVB Matrix Data Set, Using the PERSIST option'; title2 'Concatenating Two Tables into One Data Set'; set &Bname; run; proc print; run;
The data set new2 contains the two data sets created from the two COVB matrices.
Output 15.9.5: Results of the ODS OUTPUT Statement, Specifying the PERSIST Option
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.