Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Using the Output Delivery System

Example 6.5: Creating an Output Data Set from an ODS Table

The ODS OUTPUT statement creates SAS data sets from ODS tables. In the following example, the AUTOREG procedure is invoked to estimate a large number of Dickey-Fuller type regressions and part of the resulting procedure output is output to a SAS data set. The Dickey-Fuller t-statistic is then calculated and PROC MEANS is used to calculate the empirical critical values.

The data set UNITROOT contains 10,000 unit root time series.


   data unitroot;
     YLag = 0;
     do rep = 1 to 10000;
       do time = -50 to 100;
         Y = YLag + rannor(123);
         if time > 0 then output;
         YLag = Y;
       end;
     end;
   run;

Determining the Names of the ODS Tables

The purpose of the following statements is to obtain the names of the output tables produced in this PROC AUTOREG run. Note that a smaller data set, test, is used for this trial run. The ODS TRACE statement lists the trace record, and the SAS listing destination is closed so that no output is displayed.


   data test;
     YLag = 0;
       do time = -50 to 100;
         Y = YLag + rannor(123);
         if time > 0 then output;
         YLag = Y;
       end;
   run;

   ods trace on;
   ods listing close;
   proc autoreg data=test;
      model Y = YLag;
   run;
   ods trace off;
   ods listing;

Output 6.5.1: The ODS TRACE: Partial Contents of the SAS Log
     ods trace on;
     ods listing close;
     proc autoreg data=test;
        model Y = YLag;
     run;


Output Added:
-------------
Name:       Dependent
Label:      Dependent Variable
Template:   ets.autoreg.Dependent
Path:       Autoreg.Model1.Dependent
-------------

.
.
.

Output Added:
-------------
Name:       ParameterEstimates
Label:      Parameter Estimates
Template:   ets.autoreg.ParameterEstimates
Path:       Autoreg.Model1.OLSEst.ParameterEstimates
-------------

By default, the trace record is written to the SAS log, as displayed in Output 6.5.1. Note that you can alternatively specify that the information be interleaved with the procedure output in the SAS listing (see Example 6.3).

Creating the Output Data Set

In the statements that follow, the ODS OUTPUT statement writes the ODS table "ParameterEstimates" to a SAS data set called myParms. All of the usual data set options, such as the KEEP= or WHERE= options, can be used in the ODS OUTPUT statement. Thus, to modify the ParameterEstimates data set so that it contains only certain variables, you can use the data set options as follows.

   ods output ParameterEstimates = myParms
              (keep=Variable Estimate StdErr
               where=(Variable='YLag')) ;

   ods exclude all;
   proc autoreg data=unitRoot;
      by rep;
      model Y = YLag;
   run;

The KEEP= option in the ODS OUTPUT statement specifies that only the variables Variable, Estimate, and StdErr are written to the data set. The WHERE= option selects the specific variable in which we are interested , YLag. The AUTOREG procedure is again invoked. In order to limit the amount of displayed output, the ODS exclusion list is set to ALL.

In the following statements, the output data set myParms is used to create the data set TDISTN which contains the Dickey-Fuller t-statistics. PROC MEANS is then utilized to tabulate the empirical 1, 5, and 10 percent critical values. The results are displayed in Output 6.5.2.


   data tdistn;
     set myParms;
     tStat = (Estimate-1)/StdErr;
   run;

   ods select Means.Summary;
   proc means data=tDistn P1 P5 P10 fw=5;
      var tStat;
      title 'Simulated Dickey-Fuller Critical Values';
   run;

Output 6.5.2: The Empirical Critical Values, Tabulated by PROC MEANS
                    Simulated Dickey-Fuller Critical Values                     

                              The MEANS Procedure

                           Analysis Variable : tStat

                              1st      5th     10th
                             Pctl     Ptcl     Pctl
                            -----------------------
                            -3.51    -2.90    -2.59
                            -----------------------

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.