CONTENTS Procedure

Example 1: Using PROC CONTENTS to Extract Only Attributes from Data Sets

Features:

CONTENTS Procedure

PRINT Procedure

Details

Using SAS Output Delivery System (ODS), you can extract the attributes from a data set without listing the variables. There are different destinations that can be used other than RTF. The code creates a data set that contains all the attributes information from each of the data sets in the library specified, since we have used the _ALL_ keyword. For more information, see SAS Output Delivery System: User's Guide.

Program

options ls=79 nodate nocenter;
title;

data work.one;x=1;
run;
data work.two;x=2;
run;

ods listing close; 
ods output attributes=attout; 
proc contents data=work._all_;
run;

ods rtf file='cinfo.rtf';
proc print data=attout;
run;

ods rtf close;
ods listing;

Program Description

options ls=79 nodate nocenter;
title;

data work.one;x=1;
run;
data work.two;x=2;
run;

ods listing close; 
Close the listing destination.
ods output attributes=attout; 
Specify the attributes output object.
proc contents data=work._all_;
run;

Get the attributes for all data sets in the WORK library.
ods rtf file='cinfo.rtf';
Create RTF.
proc print data=attout;
run;

ods rtf close;
ods listing;

Results

PROC CONTENTS ODS Output
PROC CONTENTS ODS output