Using the Output Delivery System |
Some SAS procedures, such as PROC REG and PROC GLM, permit you to submit statements, followed by a RUN statement, followed by more statements and more RUN statements. Each group of statements, followed by a RUN statement, is called a RUN group. These procedures can produce several blocks of output for each of several RUN groups. The procedure stays active until a QUIT statement, a DATA statement, another PROC statement, or the end of the SAS session is encountered. However, ODS settings are by default cleared at RUN-group boundaries. In the following analysis, PROC REG is used to compute the covariance matrix of the estimates for two different models, and the covariance matrices are saved in a single SAS data set. The PERSIST= option in the ODS OUTPUT statement is required to make this happen. The PERSIST= option maintains ODS settings across RUN statements for procedures that support RUN-group processing.
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 necessary since polynomial effects such as Year*Year cannot be specified in the MODEL statement in PROC REG. The data are as follows:
title1 'US Population Study'; title2 'Concatenating Two Tables into One Data Set'; 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, PROC REG is used, and the ODS OUTPUT statement with the PERSIST= option creates a data set with the CovB table (the covariance matrix of the estimates):
proc reg data=USPopulation; ods output covb(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 PROC REG and the model is fit, producing a covariance matrix of the estimates with two rows and two columns. The results are displayed in Output 20.6.1 and Output 20.6.2.
US Population Study |
Concatenating Two Tables into One Data Set |
Number of Observations Read | 19 |
---|---|
Number of Observations Used | 19 |
In the next step, the YearSq variable is added to the model and the model is again fit, producing a covariance matrix of the estimates with three rows and three columns:
add YearSq; print; run; quit;
The new COVB matrix is displayed in Output 20.6.3.
US Population Study |
Concatenating Two Tables into One Data Set |
Covariance of Estimates | |||
---|---|---|---|
Variable | Intercept | Year | YearSq |
Intercept | 711450.62602 | -757.2493826 | 0.2013282694 |
Year | -757.2493826 | 0.8061328943 | -0.000214361 |
YearSq | 0.2013282694 | -0.000214361 | 5.7010894E-8 |
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 PROC REG step. This ensures that each of the COVB matrices is selected and output. The following statements display the ODS OUTPUT SAS data set and create Output 20.6.4:
proc print; run;
US Population Study |
Concatenating Two Tables into One Data Set |
Obs | _Run_ | Model | Dependent | Variable | Intercept | Year | YearSq |
---|---|---|---|---|---|---|---|
1 | 1 | MODEL1 | Population | Intercept | 20393.138485 | -10.83821461 | . |
2 | 1 | MODEL1 | Population | Year | -10.83821461 | 0.0057650078 | . |
3 | 2 | MODEL1.1 | Population | Intercept | 711450.62602 | -757.2493826 | 0.2013282694 |
4 | 2 | MODEL1.1 | Population | Year | -757.2493826 | 0.8061328943 | -0.000214361 |
5 | 2 | MODEL1.1 | Population | YearSq | 0.2013282694 | -0.000214361 | 5.7010894E-8 |
Note that even though the two COVB matrices do not have the same rows or columns, ODS automatically combines the two tables into one data set.
Copyright © SAS Institute, Inc. All Rights Reserved.