Exploring Data with PROC UNIVARIATE in SAS

Welcome back to Mindful Data Minds! In this session, we’ll dive into PROC UNIVARIATE, one of the most powerful SAS procedures for descriptive statistics and assumption testing. It’s widely used to check normality, detect outliers, and generate detailed statistical summaries.

Watch the Full Tutorial

What You Will Learn

  • How to run PROC UNIVARIATE for descriptive statistics.
  • How to analyze data by categories using CLASS.
  • How to extract specific results with ODS SELECT.
  • How to save quantiles and extreme values into datasets.
  • How to generate histograms, boxplots, and normality tests.

General Syntax

proc univariate data=<dataset>;
   var <numeric variable>;
   class <categorical variable>;
   ods select <section>;
   output out=<dataset> <options>;
   run;

Default Output

By default, PROC UNIVARIATE generates:

  • Moments → N, Mean, Std Dev, Variance, Skewness, Kurtosis, Coefficient of Variation
  • Basic Statistics → Mean, Median, Mode, Range, Interquartile Range
  • Tests for Location → t-tests for mean comparison
  • Quantiles → Percentiles (0%, 25%, 50%, 75%, 100%)
  • Extreme Observations → Five lowest and five highest values
proc univariate data=sashelp.shoes;
   var sales;
run;

Grouped Analysis with CLASS

You can analyze statistics by categories using CLASS:

proc univariate data=sashelp.shoes;
   class region;
   var sales;
run;

Produces separate results for each region (Africa, Asia, Canada, etc.).

Selecting Specific Sections

Use ODS SELECT to display only certain results:

proc univariate data=sashelp.shoes;
   var sales;
   ods select quantiles;
run;

Shows only quantiles.

Similarly:

  • ods select extremeobs; → Extreme observations
  • ods select testsfornormality; → Normality tests
  • ods select testsforlocation; → t-tests

Saving Results into a Dataset

You can save results using OUTPUT:

proc univariate data=sashelp.shoes noprint;
   var sales;
   output out=sales_qtl pctlpts=10 to 100 by 10 pctlpre=P_;
run;

Creates a dataset with percentiles at 10, 20, …, 100, named P_10, P_20, etc.

Visualizations

PROC UNIVARIATE can generate plots:

Histogram:

proc univariate data=sashelp.shoes;
   var sales;
   histogram / normal color=blue;
run;

Boxplot, Stem-and-Leaf, Normal Probability Plot:

proc univariate data=sashelp.shoes plot;
   var sales;
run;

Normality Testing

PROC UNIVARIATE provides normality tests:

proc univariate data=sashelp.shoes;
   var sales;
   ods select testsfornormality;
run;

Useful for checking assumptions before applying parametric statistical techniques.

Next Step

Continue learning by exploring the next tutorial in this series. Also subscribe to get notified about new lessons.

Have a Question?

Drop your doubts in the comments below or contact us.

Leave a Reply

Your email address will not be published. Required fields are marked *