Published on :
Administration CREATION_INTERNE

Describe a SAS Data Set

This code is also available in: Deutsch Español Français
Awaiting validation
Attention : This code requires administrator privileges.
This feature allows obtaining a detailed description of the content of a SAS© data set, including its variables, their attributes (type, length, format, informat, label) and extended attributes. The example uses the CONTENTS statement of PROC DATASETS to analyze a specific data set, hiding the list of files in the library using the NOLIST option, and redirecting the output to a new data set.
Data Analysis

Type : CREATION_INTERNE


The example creates a dummy 'group' data set in a 'health' library to ensure its autonomy, before describing its content.

1 Code Block
PROC DATASETS / DATA STEP Data
Explanation :
This example first configures system options for page and line size, suppresses the date, and sets the initial page number. It then defines a LIBNAME 'health' and creates a dummy 'group' data set with inline data to ensure the example's autonomy. PROC DATASETS is called with the NOLIST option to suppress the display of the library directory. The CONTENTS statement is used to describe the 'group' data set, with the (read=green) option which allows data to be read, and the output is saved to the 'grpout' data set. A title is also specified for the output.
Copied!
1options pagesize=40 linesize=80 nodate pageno=1;
2 
3LIBNAME health 'SAS-library';
4 
5* Create a dummy 'group' data set for autonomy;
6DATA health.group;
7 INPUT ID Name $ Score;
8 DATALINES;
9101 Alice 85
10102 Bob 92
11103 Charlie 78
12;
13RUN;
14 
15PROC DATASETS library=health nolist;
16 contents DATA=group (read=green) out=grpout;
17 title 'The Contents of the GROUP Data Set';
18RUN;
19QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved


Banner
Expert Advice
Expert
Stéphanie
Spécialiste Machine Learning et IA.
« While PROC CONTENTS is a common choice for quick inspections, using PROC DATASETS with the CONTENTS statement is the preferred "expert" approach for managing SAS libraries. It is more efficient because it allows you to manage, rename, and describe multiple files within a single step without closing and reopening the library.

When using this method, always include the OUT= option as shown in your code. This transforms the visual report into a structured SAS data set, allowing you to programmatically validate variable types or lengths before running complex transformations. Additionally, using the NOLIST option is a best practice in production environments to suppress unnecessary output and improve processing speed. »