Study guide
8.1 Detail Reporting with PROC PRINT
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
8.1 Detail Reporting with PROC PRINT
Key Takeaways Explain This Topic AI
PROC PRINT generates detail listing reports, displaying dataset observations in table format with a default Obs column unless suppressed by the NOOBS option.
The VAR statement specifies which variables to display and their exact order; omitting VAR causes all dataset variables to print in program data vector order.
The ID statement replaces the default Obs column with specified variable values as row identifiers, preventing duplicate observation numbering.
Using a BY statement requires input data to be sorted first by the BY variables, creating distinct subgroup tables, and optionally pairing with PAGEBY for forced page breaks.
The LABEL option on the PROC PRINT statement instructs SAS to display variable labels as column headers instead of variable names, while SPLIT= prints raw unformatted values.
Last updated: August 2026
8.1 Detail Reporting with PROC PRINT
Detail reporting is an essential requirement in data analysis and business reporting. In SAS, PROC PRINT serves as the primary tool for producing listing reports that print observations from a SAS dataset. By default, PROC PRINT displays all observations and all variables in the order they exist within the dataset, accompanied by an observation number column ( Obs ). However, SAS Base certification exam candidates must master the statements and options that transform default listings into customized, publication-ready reports.
1. Core Architecture and Default Behavior
When executed without additional statements or options, PROC PRINT performs a complete scan of the dataset specified in the DATA= option (or the most recently created dataset if DATA= is omitted) and outputs every row and column. proc print data=sashelp.shoes;
run;
Default Features of PROC PRINT Output:
Observation Column ( Obs ): SAS automatically generates a column named Obs on the far left that displays the observation row number (1, 2, 3, ...).
Variable Order: Variables are displayed from left to right in the exact order they appear in the dataset descriptor portion.
Column Headings: Column headers default to the SAS variable names rather than variable labels unless explicitly requested otherwise.
Formatting: Assigned permanent formats (such as DOLLAR12.2 or DATE9. ) are honored and applied to column values.
2. Key Statements in PROC PRINT
To control which variables appear, how rows are identified, and how summaries or page breaks are handled, SAS provides several dedicated statements within PROC PRINT .
Statement Syntax Primary Function & Exam Rules
VAR var variable-1 variable-2; Controls which variables are printed and their left-to-right column sequence. Variables omitted from VAR are excluded from the report.
SUM sum variable-1 variable-2; Calculates and displays column grand totals at the end of the report for specified numeric variables. If VAR is omitted, SUM prints all variables and totals the SUM variables.
ID id variable-1; Replaces the default Obs column with the specified variable(s). The ID variable values anchor the left margin of each row.
BY by variable-1; Divides report output into separate subgroup tables based on values of BY variables. Mandatory Rule: Input data MUST be pre-sorted by the BY variables!
PAGEBY pageby by-variable; Forces a physical page break whenever the value of the specified BY variable changes. Mandatory Rule: Requires an accompanying BY statement!
WHERE where expression; Selects which observations are printed. Because it is applied by the input engine, it can reference only variables that exist in the data set.
- Detailed Statement Mechanics
- The VAR Statement
The VAR statement defines the precise list and order of variables to display. If you specify a variable in the VAR statement that does not exist in the dataset, SAS produces an error in the log and halts procedure execution. proc print data=sashelp.shoes;
- var Region Subsidiary Sales Returns;
- run;
- The SUM Statement
The SUM statement computes arithmetic totals for numeric variables. When used in combination with a BY statement, SUM produces subgroup totals for each BY group as well as a grand total at the bottom of the complete report.
The ID Statement
The ID statement suppresses the default Obs column and uses one or more dataset variables to identify each row. This is particularly useful when reports are long or split across multiple pages, as the ID variable(s) repeat on the left edge of every formatted line. proc print data=sashelp.shoes;
- id Product;
- var Region Sales Inventory;
- run;
- The WHERE Statement
The official objective for PROC PRINT includes "select observations with a WHERE statement." Subsetting inside the procedure is preferable to building a filtered intermediate data set: nothing is copied, and the report reflects the live data. proc print data=sashelp.shoes noobs;
- where Region = 'Africa' and Sales > 10000;
- var Product Subsidiary Sales Returns;
- run;
WHERE in a PROC step supports the same extended operators it supports in a DATA step — BETWEEN ... AND , CONTAINS , LIKE , IS MISSING , and IN — and it filters at the input engine, so it can reference only variables that already exist in the data set.
The BY and PAGEBY Statements
Using a BY statement creates distinct sub-tables for each unique BY group. Prior to executing PROC PRINT with a BY statement, you must execute PROC SORT to order the dataset by those identical BY variables. Attempting to run PROC PRINT with a BY statement on unsorted data results in a fatal error: ERROR: Data set WORK.MYDATA is not sorted in order of BY variables.
When reports are large, PAGEBY controls pagination. Note that PAGEBY can only reference a variable that is listed in the BY statement. proc sort data=sashelp.shoes out=work.shoes_sorted;
- by Region Subsidiary;
- run;
- proc print data=work.shoes_sorted;
- by Region Subsidiary;
- pageby Region;
- var Product Sales Returns Profit;
- sum Sales Returns Profit;
- run;
- 3. Essential PROC PRINT Options
Options are placed directly on the PROC PRINT header statement after the dataset specification. proc print data=dataset-name <options>;
Summary of Critical PROC PRINT Options:
NOOBS
Suppresses the automatic Obs column from appearing in the printed output.
Used when row numbers are unnecessary or uninformative for the report audience.
Exam Note: If both ID and NOOBS are specified, SAS suppresses the Obs column and uses the ID variable as the leftmost column.
LABEL
Instructs SAS to use variable labels as column headers instead of variable names.
If a variable has no label assigned, SAS defaults back to displaying the variable name for that specific column header.
Exam Note: Simply assigning labels in a LABEL statement inside PROC PRINT is NOT sufficient to display them—you MUST include the LABEL option on the PROC PRINT statement line!
SPLIT='character'
Names a split character that forces a line break inside a column heading, letting long labels wrap onto several lines instead of stretching the column.
SPLIT= implies the LABEL option, so you do not code both. Everything to the left of the split character becomes line 1 of the heading, everything after it line 2, and so on.
- The split character is consumed by the heading and never printed. proc print data=work.employees split='*';
- var EmployeeID LastName Salary;
- label Salary = "Annual Gross*Salary (USD)"
- LastName = "Employee*Surname";
- run;
- /* The Salary heading prints on two lines: Annual Gross
- Salary (USD) */
Exam Note: To show labels you need either LABEL or SPLIT= on the PROC PRINT statement. A LABEL statement alone changes nothing in the printed output. To display raw values instead of formatted ones there is no UNFORMATTED option in PROC PRINT — remove the format instead, either with format Variable; inside the
step (which clears the format for that step) or by not assigning one.
N="string" or N
Displays the total number of observations at the end of the report or at the end of each BY group. You can supply an optional text string, e.g., N="Total Accounts: " .
BLANKLINE=n
Inserts n blank lines between observations in the printed output to enhance visual readability. proc print data=sashelp.shoes noobs label n="Rows printed: ";
- var Region Product Sales;
- label Sales="Total Gross Sales ($)";
- run;
- 4. Synthesis and Common Exam Scenarios
Let's examine how statements and options interact in typical SAS Base certification questions: /* Advanced Detail Reporting Example */
- proc sort data=sashelp.class out=work.class_sorted;
- by Sex;
- run;
- proc print data=work.class_sorted noobs label;
- by Sex;
- id Name;
- var Age Height Weight;
- sum Weight;
- label Height="Height (Inches)" Weight="Weight (Pounds)";
- run;
Key Exam Traps to Remember:
Missing SORT Step: Any BY statement in PROC PRINT requires a prior PROC SORT step. If the dataset is not sorted or indexed by the BY variable, the step terminates with an error.
Label Option Omission: If a student writes label Height="Height in Inches"; inside PROC PRINT but omits the LABEL option on the proc print data=... line, SAS prints variable names ( Height ), NOT variable labels.
PAGEBY Without BY: Specifying pageby Region; without a by Region; statement causes a syntax error.
ID vs NOOBS: Specifying ID without NOOBS still suppresses the Obs column automatically because the ID variable replaces Obs .