Fundamentals of Programming in SAS. James Blum
Чтение книги онлайн.
Читать онлайн книгу Fundamentals of Programming in SAS - James Blum страница 9
ods trace on;
proc contents data=sashelp.cars;
run;
proc contents data=sashelp.cars varnum;
run;
There are many ODS statements available in SAS, some act globally—they remain in effect until another statement alters that effect—while others act locally—for the execution of the current or next procedure. The TRACE is a recording of all output objects generated by the code execution. ON delivers this information to the SAS log; OFF suppresses it. The effect of ODS TRACE is global, the ON or OFF condition only changes with a submission of a new ODS TRACE statement that makes the change. The typical default at the invocation of a SAS session is OFF.
The VARNUM option in PROC CONTENTS rearranges the table showing the variable information from alphabetical order to position order. This also represents a change in the name of the table as indicated in the TRACE information shown in the log.
Log 1.5.1A: Using ODS TRACE to Track Output
74 ods trace on;
75 proc contents data=sashelp.cars;
76 run;
Output Added:
-------------
Name: Attributes
Label: Attributes
Template: Base.Contents.Attributes
Path: Contents.DataSet.Attributes
-------------
Output Added:
-------------
Name: EngineHost
Label: Engine/Host Information
Template: Base.Contents.EngineHost
Path: Contents.DataSet.EngineHost
-------------
Output Added:
-------------
Name: Variables
Label: Variables
Template: Base.Contents.Variables
Path: Contents.DataSet.Variables
-------------
Output Added:
-------------
Name: Sortedby
Label: Sortedby
Template: Base.Contents.Sortedby
Path: Contents.DataSet.Sortedby
-------------
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.29 seconds
cpu time 0.20 seconds
Log 1.5.1B: Using ODS TRACE to Track Output
78 proc contents data=sashelp.cars varnum;
79 run;
Output Added:
-------------
Name: Attributes
Label: Attributes
Template: Base.Contents.Attributes
Path: Contents.DataSet.Attributes
-------------
Output Added:
-------------
Name: EngineHost
Label: Engine/Host Information
Template: Base.Contents.EngineHost
Path: Contents.DataSet.EngineHost
-------------
Output Added:
-------------
Name: Position
Label: Varnum
Template: Base.Contents.Position
Path: Contents.DataSet.Position
-------------
Output Added:
-------------
Name: Sortedby
Label: Sortedby
Template: Base.Contents.Sortedby
Path: Contents.DataSet.Sortedby
-------------
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.13 seconds
cpu time 0.07 seconds
Each table generated by PROC CONTENTS has a name and a label; sometimes these are the same. Labels are free-form, while names follow the SAS naming conventions described earlier which are revisited in Section 1.6.2. The SAS Documentation also includes lists of ODS table names for each procedure, along with information about which are generated as default procedure output and which tables are generated as the result of including specific options. From the traces shown in Logs 1.5.1A and 1.5.1B, the rearrangement of the variable information when using the VARNUM option is actually a replacement of the Variables table with the Position table.
If ODS table names (and other output object names, such as graphs) are known, other forms of ODS statements are available to choose which output to include or not. Program 1.5.2 shows how to modify each of the CONTENTS procedures in Program 1.5.1 to only display the variable information.
Program 1.5.2: Using ODS SELECT to Subset Output
proc contents data=sashelp.cars;
ods select Variables;
run;
proc contents data=sashelp.cars varnum;
ods select Position;
run;
ODS SELECT and ODS EXCLUDE each support a space-separated list of output object