Study guide

8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY

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.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY

Key Takeaways Explain This Topic AI

PROC MEANS prints summary statistics to the output window by default, whereas PROC SUMMARY produces no printed output unless the PRINT option is specified.

When no statistic keywords are specified, PROC MEANS calculates N, MEAN, STD (Standard Deviation), MIN, and MAX for all numeric variables.

The CLASS statement performs subgroup analysis without requiring pre-sorted data, while the BY statement requires data sorted by BY variables.

The OUTPUT OUT= statement creates a SAS dataset containing summary statistics, automatically creating TYPE and FREQ variables when CLASS is used, and its AUTONAME option names the result variables by combining the analysis variable with the statistic keyword (e.g., Sales_Mean).

WAYS n restricts OUTPUT OUT= to n-way CLASS combinations and NWAY keeps only the fully crossed level, replacing manual TYPE filtering.

Last updated: August 2026

8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY

Descriptive statistical analysis is a core data reporting task. In SAS, PROC MEANS and PROC SUMMARY are sister procedures designed to compute summary statistics for numeric variables across an entire dataset or within specific categorical subgroups. Both procedures share virtually identical syntax and analytical engines, but differ in their default output behavior.

1. PROC MEANS vs. PROC SUMMARY: The Key Difference

Understanding the fundamental distinction between PROC MEANS and PROC SUMMARY is a frequent SAS certification topic:

PROC MEANS: Prints descriptive statistics to the active output destination (Listing, HTML, PDF) by default . To suppress printed output, you must explicitly add the NOPRINT option.

PROC SUMMARY: Computes identical statistics but produces NO printed output by default . To print output from PROC SUMMARY, you must explicitly include the PRINT option on the procedure statement. /* PROC MEANS prints output automatically */

  • proc means data=sashelp.shoes;
  • var Sales;
  • run;
  • /* PROC SUMMARY computes statistics silently (typically paired with OUTPUT OUT=) */
  • proc summary data=sashelp.shoes;
  • var Sales;
  • output out=work.sales_summary mean=AvgSales;
  • run;
  • /* PROC SUMMARY with PRINT option behaves like PROC MEANS */
  • proc summary data=sashelp.shoes print;
  • var Sales;
  • run;
  • 2. Default Statistics vs. Explicit Keywords

When PROC MEANS is executed without specifying statistic keywords, SAS computes a standard set of five default statistics for every numeric variable in the VAR statement (or all numeric variables in the dataset if VAR is omitted):

N : Number of non-missing values.

MEAN : Arithmetic average.

STD : Standard deviation.

MIN : Minimum value.

MAX : Maximum value.

Specifying Explicit Statistics Keywords

If you list any statistic keyword on the PROC MEANS statement line, SAS overrides the five defaults and calculates ONLY the statistics you explicitly requested! /* Requests ONLY N, NMISS, MEAN, and MEDIAN */

  • proc means data=sashelp.shoes n nmiss mean median maxdec=2;
  • var Sales Returns;
  • run;

Frequently Tested Statistic Keywords:

  • Keyword Statistical Description
  • N Count of non-missing observations
  • NMISS Count of missing numeric observations
  • MEAN Arithmetic mean
  • STD Sample standard deviation
  • MIN / MAX Minimum / Maximum values
  • SUM Sum total of values
  • MEDIAN 50th percentile (middle value)

P1 , P5 , P10 , P25 , P50 , P75 , P90 , P95 , P99 Specific percentile values (e.g., P25 = 25th percentile / lower quartile)

  • QRANGE Interquartile range ( P75 minus P25 )
  • CLM 95% two-sided confidence limit for the mean
  • STDERR Standard error of the mean
  • VAR Sample variance
  • 3. Options on the Procedure Statement

MAXDEC=n : Specifies the maximum number of decimal places ( n from 0 to 8) to display in printed statistics.

NONOBS : Suppresses the display of the total observation count column in printed output.

NOPRINT : Suppresses all printed output (used primarily when creating output datasets via OUTPUT OUT= ).

DATA=dataset : Identifies the input dataset.

4. Subgroup Analysis: CLASS vs. BY Statements

Both CLASS and BY statements allow you to analyze data within categorical subgroups, but their underlying execution mechanics differ fundamentally.

Feature CLASS Statement BY Statement

Sorting Requirement NO pre-sorting required! SAS processes unsorted data using hash tables. MANDATORY pre-sorting! Input dataset MUST be sorted by BY variables beforehand.

Output Display Consolidates all subgroups into a single readable summary table. Produces separate, individual summary tables with distinct headers for each BY group.

Output Dataset Structure Creates _TYPE_ and _FREQ_ automatic variables representing hierarchical combinations. Does NOT create _TYPE_ variable combinations; outputs distinct rows per BY group.

Performance Highly efficient for high-cardinality categorical variables. Best when data is already sorted or when separate physical output sections are required. /* CLASS Example - Unsorted Data OK */

  • proc means data=sashelp.shoes maxdec=2;
  • class Region Product;
  • var Sales;
  • run;
  • /* BY Example - Pre-sorting Mandatory */
  • proc sort data=sashelp.shoes out=work.shoes_sorted;
  • by Region;
  • run;
  • proc means data=work.shoes_sorted maxdec=2;
  • by Region;
  • var Sales;
  • run;
  • 5. Output Datasets: The OUTPUT OUT= Statement

The OUTPUT OUT= statement directs SAS to write computed statistics into a new SAS dataset. proc means data=sashelp.shoes noprint;

  • class Region;
  • var Sales Returns;
  • output out=work.shoes_summary
  • mean=AvgSales AvgReturns
  • sum=TotalSales TotalReturns;
  • run;

Syntax Rules for OUTPUT OUT= :

OUT=dataset-name : Names the destination output dataset.

statistic=new-variable-list : Maps statistics to output variable names. The order of variables in new-variable-list matches the order of variables in the VAR statement.

The AUTONAME Option: When added to the OUTPUT statement, SAS automatically creates output variable names by combining the original variable name with the statistic keyword name, eliminating the need to type manual variable lists. proc means data=sashelp.shoes noprint;

  • class Region;
  • var Sales Returns;
  • output out=work.shoes_autonamed
  • mean= sum= / autoname;
  • run;
  • /* Creates variables: Sales_Mean, Returns_Mean, Sales_Sum, Returns_Sum */
  • Automatic Variables in Output Datasets: _TYPE_ and _FREQ_ when using CLASS

When a CLASS statement is used with OUTPUT OUT= , SAS creates two automatic variables in the output dataset:

_FREQ_ : Contains the number of observations included in that specific subgroup calculation.

_TYPE_ : A numeric variable indicating the combination of CLASS variables used to aggregate the statistics:

_TYPE_ is a binary code : with CLASS A B; , the leftmost CLASS variable owns the high-order bit.

_TYPE_ = 0 : Grand total across all observations (no CLASS variable used for grouping).

_TYPE_ = 1 : Statistics grouped by B only (the last CLASS variable listed).

_TYPE_ = 2 : Statistics grouped by A only (the first CLASS variable listed).

_TYPE_ = 3 : Statistics grouped by A and B together (every CLASS variable).

Restricting the Aggregation Levels with WAYS and NWAY

By default OUTPUT OUT= writes every _TYPE_ combination, which is 2^n rows-worth of levels for n CLASS variables. Two mechanisms narrow that down:

WAYS n; — a statement that requests only the n -way combinations. ways 1; keeps single-variable summaries; ways 0 2; keeps the grand total plus every two-variable combination.

NWAY — an option on the PROC MEANS statement that keeps only the highest-order combination (all CLASS variables crossed), equivalent to the maximum _TYPE_ . /* Only the one-way summaries: Region alone, then Product alone */

  • proc means data=sashelp.shoes noprint;
  • class Region Product;
  • ways 1;
  • var Sales;
  • output out=work.oneway_stats sum=TotalSales;
  • run;
  • /* Only the fully crossed Region * Product cells */
  • proc means data=sashelp.shoes nway noprint;
  • class Region Product;
  • var Sales;
  • output out=work.crossed_stats sum=TotalSales;
  • run; /* Example of filtering specific aggregation level in DATA step */
  • data work.region_totals_only;
  • set work.shoes_summary;
  • if _type_ = 1; /* Keeps only the level-1 CLASS summaries */
  • run;