DATASETS Procedure

Example 8: ODS Output

Features:

CONTENTS Statement

The example shows how to get PROC CONTENTS output into an ODS output data set for processing.
For more information, see SAS Output Delivery System: User's Guide.

Program

title1 "PROC CONTENTS ODS Output";

options nodate nonumber nocenter formdlim='-';

data a;
   x=1;
run;
ods output attributes=atr
           variables=var
           enginehost=eng;
ods listing close;

proc contents data=a;
run;
ods listing;

title2 "all Attributes data";

proc print data=atr noobs;
run;

title2 "all Variables data";

proc print data=var noobs;
run;

title2 "all EngineHost data";

proc print data=eng noobs;
run;
ods output attributes=atr1(keep=member cvalue1 label1
   where=(attribute in ('Data Representation','Encoding'))
   rename=(label1=attribute cvalue1=value))
   attributes=atr2(keep=member cvalue2 label2
   where=(attribute in ('Observations', 'Variables'))
   rename=(label2=attribute cvalue2=value));


ods listing close;

proc contents data=a;
run;

ods listing;

data final;
   set atr1 atr2;
run;

title2 "example of post-processing of ODS output data";

proc print data=final noobs;
run;

ods listing close;

Program Description

title1 "PROC CONTENTS ODS Output";

options nodate nonumber nocenter formdlim='-';

data a;
   x=1;
run;
Use the ODS OUTPUT statement to specify data sets to which CONTENTS data is directed.
ods output attributes=atr
           variables=var
           enginehost=eng;
Temporarily suppress output to the lst.
ods listing close;

proc contents data=a;
run;
Resume output to the lst.
ods listing;

title2 "all Attributes data";

proc print data=atr noobs;
run;

title2 "all Variables data";

proc print data=var noobs;
run;

title2 "all EngineHost data";

proc print data=eng noobs;
run;
Select specific data from ODS output.
ods output attributes=atr1(keep=member cvalue1 label1
   where=(attribute in ('Data Representation','Encoding'))
   rename=(label1=attribute cvalue1=value))
   attributes=atr2(keep=member cvalue2 label2
   where=(attribute in ('Observations', 'Variables'))
   rename=(label2=attribute cvalue2=value));


ods listing close;

proc contents data=a;
run;

ods listing;

data final;
   set atr1 atr2;
run;

title2 "example of post-processing of ODS output data";

proc print data=final noobs;
run;

ods listing close;

Results

All Attributes Data
All Attributes Data
All Variables Data
All Variables Data
All EngineHost Data
All EngineHost Data
PROC CONTENTS for All EngineHost Data
PROC CONTENTS for All EngineHost Data
Post-processing of ODS Output Data
Post-processing of ODS Output Data