Study guide
2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS
SAS Certified Specialist: Base Programming Using SAS 9.4 A00-231
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: SAS Base Programming Exam Overview
1.1 A00-231 Exam Format, Scoring & Test-Day Logistics 1.2 Official Content Areas, Weights & Study Plan
2 Chapter 2: Accessing & Creating SAS Data Structures
2.1 SAS Environment, Syntax Rules, & Data Step Basics 2.2 SAS Data Libraries & the LIBNAME Statement 2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS 2.4 Importing Delimited & Excel Data with PROC IMPORT 2.5 Raw Data Ingestion with INFILE and INPUT Statements
3 Chapter 3: Managing & Combining SAS Data Sets
3.1 Reading SAS Data Sets with the SET Statement 3.2 Combining Data Sets: Concatenating & Interleaving 3.3 Match-Merging with BY Statements & FIRST./LAST. Processing 3.4 Controlling Data Output & Variable Selection (KEEP, DROP, RENAME, OBS=)
4 Chapter 4: Data Transformation & Conditional Logic
4.1 Creating & Modifying Variables with Assignment Statements 4.2 Modifying Variable Attributes with LENGTH, LABEL, FORMAT & RENAME= 4.3 Conditional Processing: IF-THEN/ELSE Statements & WHERE Subsetting 4.4 Accumulating Totals & Subtotals (RETAIN & Sum Statement) 4.5 Processing Data Iteratively with DO Loops
5 Chapter 5: SAS Functions & Data Type Conversions
5.1 Character Functions for String Manipulation 5.2 Numeric & Mathematical Functions 5.3 Working with SAS Dates, Times, & Intervals 5.4 Reading & Displaying Dates with Informats and Formats 5.5 Explicit & Implicit Data Type Conversions (INPUT & PUT)
6 Chapter 6: Restructuring Data & Program Maintenance
6.1 SAS Array Processing for Multi-Variable Transformations 6.2 Sorting Data Sets with PROC SORT 6.3 Restructuring Data Sets with PROC TRANSPOSE 6.4 Creating & Applying Custom Formats with PROC FORMAT 6.5 Simplifying Programs with Macro Variables (%LET)
7 Chapter 7: Error Handling & Debugging SAS Programs
7.1 SAS Log Analysis & Diagnostic Messages 7.2 Syntax vs. Logic Errors & Phasing 7.3 Debugging Techniques with _ERROR_, _N_, & PUT Statements 7.4 Identifying Logic Errors with the PUTLOG Statement 7.5 Handling Missing Values & Preventing Calculation Propagations
8 Chapter 8: Summary & Detail Data Reporting
8.1 Detail Reporting with PROC PRINT 8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY 8.3 Frequency & Categorical Analysis with PROC FREQ 8.4 Screening Extreme & Missing Values with PROC UNIVARIATE 8.5 Custom Tabular Reports with PROC REPORT & PROC TABULATE
9 Chapter 9: ODS Output Delivery & Data Export
9.1 Output Delivery System (ODS) Architecture Basics 9.2 Generating PDF, HTML, & RTF Output Destinations 9.3 Exporting Reports to Excel with ODS EXCEL & XLSX 9.4 Generating CSV, PowerPoint & Other ODS Destinations 9.5 Customizing ODS Titles, Footnotes, & Global Options 9.6 Exporting SAS Data Sets with PROC EXPORT & the XLSX Engine
2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS
Key Takeaways Explain This Topic AI
PROC CONTENTS prints the descriptor portion of a data set: variable names, types, lengths, positions, formats, informats, labels, and the observation and variable counts.
DATA=libref. ALL lists every member of a library, and adding NODS suppresses the per-data-set variable detail to leave only the directory listing.
VARNUM prints variables in creation (PDV) order instead of the default alphabetical order, which is how you confirm the physical column sequence.
OUT= writes the descriptor metadata to a SAS data set so that program logic can react to variable names, types, and lengths.
PROC DATASETS manages library members in place - DELETE, CHANGE, KILL, APPEND, MODIFY - without copying the data, and it ends with QUIT rather than RUN.
Last updated: August 2026
2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS
Quick Answer: PROC CONTENTS is a read-only reporting procedure that prints the descriptor portion of a SAS data set — variable names, types, lengths, positions, formats, and counts. PROC DATASETS is a utility procedure that manages library members in place: deleting, renaming, appending, and modifying attributes without rewriting the data. The content guide names investigating libraries with base utility procedures as a main objective, and PROC CONTENTS is the procedure it calls out by name.
Every SAS data set has two parts. The data portion holds the observations. The descriptor portion holds the metadata: how many observations and variables exist, when the data set was created, which engine wrote it, and, for each variable, its name, type, length, position, format, informat, and label. PROC CONTENTS is how you read the descriptor portion without reading a single observation.
- 1. PROC CONTENTS on a Single Data Set proc contents data=sashelp.class;
- run;
The output arrives in two blocks:
Data set attributes — member name, type, engine, creation and modification datetimes, observation count, variable count, observation length, whether the data set is sorted and by what, and compression status.
Alphabetic list of variables and attributes — one row per variable with # (position in the PDV), Variable , Type , Len , and, where assigned, Format , Informat , and Label .
Exam Trap: the variable table is titled Alphabetic List of Variables for a reason. PROC CONTENTS sorts
variables alphabetically by default , not in the order they physically occur. The # column still shows the true
position, and the VARNUM option re-sorts the listing into that creation order. /* Print variables in physical PDV order rather than alphabetically */
- proc contents data=sashelp.class varnum;
- run;
- 2. Investigating an Entire Library
Two special values turn PROC CONTENTS from a single-data-set report into a library survey.
Syntax Result
data=libref._ALL_ Reports on every member of the library, one full descriptor block per data set, preceded by a directory listing
data=libref._ALL_ nods Prints only the directory listing — member names, types, and sizes — and suppresses the per-data-set variable detail libname retail 'C:\SAS_Data\RetailStore';
- /* Full descriptor for every member - can be very long */
- proc contents data=retail._all_;
- run;
- /* Just the inventory of what lives in the library */
- proc contents data=retail._all_ nods;
- run;
Exam Trap: NODS is only legal together with _ALL_ . Coding proc contents data=retail.inventory nods; produces an error, because there is no directory to print for a single member. The mnemonic is " NO D ata S et
details".
Other Frequently Tested PROC CONTENTS Options
OUT=SAS-data-set — writes the descriptor metadata to a data set instead of (or in addition to) printing it. Columns include MEMNAME , NAME , TYPE (1 = numeric, 2 = character), LENGTH , VARNUM , FORMAT , and LABEL . This is how programs make decisions about variables they cannot hardcode.
NOPRINT — suppresses the printed report, normally paired with OUT= .
SHORT — prints just a compact list of variable names with no attribute columns.
DIRECTORY — prints the library directory along with the single-data-set report. /* Capture metadata, then act on it: list every character variable */
- proc contents data=work.customers out=work.meta(keep=name type length) noprint;
- run;
- proc print data=work.meta;
- where type = 2; /* 2 = character, 1 = numeric */
- title "Character variables in WORK.CUSTOMERS";
- run;
- 3. PROC DATASETS: Managing Members in Place
PROC DATASETS performs library housekeeping without copying data, which makes it dramatically faster than a DATA step for the same task. It is a RUN-group procedure: statements execute at each RUN; , and the procedure stays open until it hits QUIT; . proc datasets library=work nolist;
- change old_sales = sales_2026; /* rename a data set */
- delete temp1 temp2 scratch; /* delete specific members */
- modify sales_2026; /* open one member for edits */
- label Amount = 'Gross Amount (USD)';
- format Amount dollar12.2;
- rename Amt = Amount;
- append base = master_sales
- data = sales_2026; /* fast vertical append */
- quit;
- Statement / option Effect
- LIBRARY= (or LIB= ) Names the target library; defaults to WORK if omitted
- NOLIST Suppresses the automatic library directory listing
- CHANGE old=new Renames a data set
- DELETE name-list Deletes the named members
- KILL Deletes every member in the library — irreversible
- MODIFY name Opens one member so LABEL , FORMAT , and RENAME can change attributes in place
- APPEND BASE= DATA= Adds the observations of DATA= to the end of BASE= without rewriting BASE=
- CONTENTS Runs the equivalent of PROC CONTENTS from inside PROC DATASETS
Exam Trap: PROC DATASETS ends with QUIT; , not RUN; . PROC SORT , PROC PRINT , PROC MEANS , and PROC FREQ end with RUN; . PROC DATASETS , PROC SQL , and PROC FORMAT with run-groups belong to the family
that stays resident until QUIT; is submitted.
CONTENTS versus DATASETS: When to Use Which
- Need Procedure
- Inspect variables, types, lengths, formats PROC CONTENTS
- List every member of a library PROC CONTENTS ... _ALL_ NODS or PROC DATASETS directory
- Capture metadata into a data set PROC CONTENTS ... OUT= NOPRINT
- Rename, delete, or append members PROC DATASETS
- Change a label, format, or variable name without rewriting rows PROC DATASETS ... MODIFY
PROC CONTENTS never changes anything, which is exactly why it is the safe first step when you inherit an unfamiliar library.