Skip to main content
v2026.11,986 entries · CC-BY 4.0

PROC UNIVARIATE SAS: Syntax and Output

Use PROC UNIVARIATE to summarize numeric research data, request normality tests and save named statistics and custom percentiles.

Written and maintained by CASRAI Editorial Board

Published

On this page

PROC UNIVARIATE in SAS summarizes numeric variables with descriptive statistics, quantiles, location tests and optional normality tests and plots. Use an explicit DATA= dataset and VAR statement, then add OUTPUT to save named statistics. The worked example below connects the displayed results to a reusable summary dataset and shows which settings matter when comparing SAS with R.

What PROC UNIVARIATE is used for in research

SAS PROC UNIVARIATE supports distribution analysis: describing the center and spread of a measurement, examining extreme observations, estimating percentiles and assessing distributional assumptions. It can also request confidence limits and robust estimates. The useful starting point is a specific measurement and an explicit analysis question, such as describing the distribution of an assay response before reporting its summary statistics.

Keep three outputs distinct. Descriptive measures summarize the observed values. Tests for location assess a specified mean or location value, controlled by MU0=. Tests for normality assess a distributional hypothesis and require the NORMAL option. A location-test p-value does not answer the normality question. This distinction matters because the procedure can display several statistical tables from the same invocation.

The workflow here emphasizes selected statistics and an output dataset. A graph is another product, rather than the only result of the procedure. Naming the analysis variables also keeps numeric identifiers out of the measurement summaries. Use the PROC CONTENTS guide to inspect dataset variables and metadata when the input structure is uncertain.

How to install or access PROC UNIVARIATE

Access PROC UNIVARIATE through a SAS programming environment; it is invoked by a SAS procedure statement. For learning, SAS provides cloud access through SAS OnDemand for Academics and SAS Studio. The official support page directs independent learners to its registration application and provides registration, login and data-upload resources.

Follow those official registration instructions, open the SAS Studio environment and submit a SAS program. SAS describes Studio as an interface for writing and submitting programs. Its OnDemand learning access should be distinguished from the authorization your institution provides for a research project. For project work, use the SAS environment and data access approved for that project.

The examples use documented SAS 9.4 procedure syntax rather than a version-specific graphical task. They require a dataset containing the numeric variable named in VAR. The introduction to DATA and PROC steps in SAS explains how the data-creation step and procedure step fit together.

How to run PROC UNIVARIATE in SAS step by step

  1. Create a small, known input. This illustrative composite contains ten artificial measurement values, with no missing observations. It represents no actual study or laboratory result. The DATA, INPUT and DATALINES structure follows SAS’s documented data-entry example, with a single numeric response substituted for its variables.

    data work.assay;
      input response @@;
      datalines;
    10 12 14 16 18 20 22 24 26 28
    ;
    run;

    The double at sign is part of the input statement. Keep the semicolon terminating the data separate from the values, and complete the data step before running the analysis.

  2. Name the dataset and measurement. DATA= selects the input dataset; VAR identifies the analysis variable. Specifying both makes the program’s target visible. SAS documents that omitting DATA= uses the most recently created dataset, which makes an implicit selection vulnerable to an earlier change in the program.

    proc univariate data=work.assay;
      var response;
    run;

    Start with this minimal invocation when checking a new input. Establish that the intended measurement is being analyzed before adding tests or export fields.

  3. Request the tests and plots deliberately. NORMAL requests the Tests for Normality table. With ODS Graphics enabled, PLOTS requests a panel containing a horizontal histogram, a box plot and a normal probability plot. Without ODS Graphics, the documented plot output uses line-printer displays instead.

    ods graphics on;
    title 'Illustrative assay response';
    proc univariate data=work.assay normal plots pctldef=5;
      var response;
    run;
    title;

    PCTLDEF=5 explicitly records the documented default percentile definition. It helps make the analysis settings visible when another analyst reproduces the summary in a different system. The title labels the artificial example; it is not evidence of a real assay.

  4. Save the statistics needed downstream. OUTPUT creates a dataset of requested statistics. It requires VAR and either named statistical keywords or the percentile options. Here the keywords name the output variables, while PCTLPTS= and PCTLPRE= create additional percentile variables.

    proc univariate data=work.assay pctldef=5;
      var response;
      output out=work.assay_summary
        n=n_response
        nmiss=n_missing
        mean=mean_response
        std=sd_response
        median=median_response
        pctlpts=25 75 97.5
        pctlpre=response_;
    run;

    With no BY or CLASS statement, this output dataset has one observation. Its variables include the named statistics and response_25, response_75 and response_97_5. The underscore in the last name replaces the decimal point. These fields summarize the input; they are not ten copies of the original observations.

  5. Check the saved values against the input. For this artificial sequence, the ten values sum to 190, so the mean is 190 ÷ 10 = 19. The median is the average of the fifth and sixth ordered values: (18 + 20) ÷ 2 = 19. The saved counts should be n_response = 10 and n_missing = 0.

    The squared deviations from 19 sum to 330. SAS’s default unweighted variance divisor is n − 1, giving 330 ÷ 9 = 36.6667 and a standard deviation of approximately 6.0553. These arithmetic checks establish the scale and denominator of the example without treating a normality-test result as a prerequisite for calculating a descriptive summary.

How to read the output

Read the variable label and table name before reading any statistic. SAS’s descriptive-statistics example separates Basic Statistical Measures from Quantiles; the procedure’s additional options produce additional tables. For the artificial response values, the mean and median agree at 19, while the minimum and maximum are 10 and 28. Agreement between two summary measures describes this example; it does not establish a distributional model.

Separate location tests from normality tests

MU0= specifies the null mean or location value for location tests and defaults to zero. The NORMAL option instead requests Shapiro-Wilk and empirical-distribution-function tests, including Kolmogorov-Smirnov, Anderson-Darling and Cramér–von Mises. In the linked SAS 9.4 documentation, Shapiro-Wilk is computed for sample sizes up to 2,000.

Compare a normality-test p-value with the significance level selected for the analysis. SAS describes rejection when that p-value is below the predetermined level. Its documentation also cautions against using normality tests alone: large samples can detect small departures, while small samples can fail to detect meaningful departures. Examine the plots and descriptive statistics alongside the test rather than treating a large p-value as proof of normality.

Distinguish displayed tables from saved statistics

The OUTPUT statement controls fields in the saved dataset. Additional percentiles requested with PCTLPTS= are written there and are not added to the printed percentile list. Consequently, a missing 97.5th-percentile entry in the displayed Quantiles table does not establish that the request failed. Inspect response_97_5 in work.assay_summary.

STD names the standard deviation keyword; STDMEAN or STDERR names the standard error of the mean. Choose the field that matches the quantity being reported. The SAS standard deviation guide develops that distinction and the separate use of the STD function. Keep the output variable name descriptive enough that a later table-building step can preserve the distinction.

Choose the saved dataset’s shape

OUTPUT and OUTTABLE= provide different arrangements. The OUTPUT example gives explicit names to selected statistics and, without grouping statements, produces one observation. When several variables are analyzed, the names after each statistical keyword correspond to their VAR order. This arrangement suits a deliberately specified set of fields, but the naming lists need to stay aligned with the variable list.

By contrast, the PROC UNIVARIATE statement’s OUTTABLE= option creates a tabular dataset with one observation per analysis variable. That distinction becomes useful when reviewing many measurements: choose the structure that the next analysis step expects, and check its rows and variable names before joining it to another dataset. A summary dataset should not be mistaken for observation-level data simply because both are SAS datasets.

Troubleshooting PROC UNIVARIATE

The results describe an unexpected dataset

Check DATA= first. Without it, SAS uses the most recently created dataset. Then check the variable list and spelling in VAR. Making both selections explicit is a reproducibility safeguard: a later data-preparation step should not silently change which data the analysis uses.

The procedure produces no descriptive tables

Check for NOPRINT and ODS selection statements. NOPRINT suppresses the descriptive tables created by the PROC UNIVARIATE statement and can be useful when only a saved dataset is wanted. Separately, SAS’s example uses ODS SELECT BasicMeasures Quantiles to restrict displayed tables. A display restriction and a calculation request serve different purposes; inspect both when expected output is absent.

Custom percentile fields are absent or mislabeled

PCTLPTS= and PCTLPRE= must be used together. With multiple analysis variables, list prefixes in the same order as VAR. Ordinary keyword output names also map positionally: the first name after MEAN= corresponds to the first VAR variable. Supplying fewer output names can therefore save fewer variables than intended.

Use PCTLNAME= when explicit suffixes make the schema clearer, listing them in the same order as the requested percentiles. SAS permits multiple OUTPUT statements, so separate summary datasets can be created when one wide naming scheme would be difficult to review.

A normality test or confidence limit is unavailable

Check the option’s restrictions before treating absence as a software failure. SAS documents that NORMAL does not apply with a WEIGHT statement. CIBASIC requests normal-theory confidence limits for the mean, standard deviation and variance and requires the default VARDEF=DF. These are conditions on particular calculations, rather than interchangeable switches for producing more output.

Free alternatives to PROC UNIVARIATE

R is a free software environment for statistical computing and graphics. Its functions can replace individual parts of this workflow. The alternatives below are task-specific functions, rather than a single command that reproduces every SAS table. Retain the same observations and document the relevant settings when comparing results.

R alternative Task it replaces Setting to inspect
stats::quantile() Requested sample percentiles Set probs explicitly, choose type, and decide whether to remove missing values with na.rm.
stats::shapiro.test() Shapiro-Wilk normality test R accepts between 3 and 5,000 nonmissing observations; this differs from the documented SAS limit.

For example, quantile(x, probs = c(0.25, 0.75, 0.975), type = 2, na.rm = TRUE) requests three percentiles from numeric vector x using the algorithm R documents as corresponding to the SAS default. SAS PCTLPTS uses percentages such as 97.5, while R probs uses probabilities such as 0.975. Matching the apparent numbers without matching their scale changes the request.

R’s default quantile algorithm is type 7, whereas its manual identifies type 2 as the SAS default counterpart. A difference in percentiles can therefore come from algorithm choice even when the input values agree. The data table below compiles these settings and the normality-test limits into a reference for reviewing a SAS-to-R reproduction. Compare settings before interpreting a disagreement as changed research data.

Sources

Data: SAS and R distribution-analysis settings

Original crosswalk compiled from SAS PROC UNIVARIATE and R stats documentation. It compares percentile argument scales, default and matched quantile algorithms, and documented Shapiro-Wilk sample limits. The settings refer to the linked SAS 9.4 and R manuals.

SAS and R distribution-analysis settings
SettingSAS PROC UNIVARIATER statsInterpretation
97.5th-percentile requestPCTLPTS=97.5 with PCTLPRE=quantile(x, probs=0.975)SAS uses a percentage; R uses a probability.
Default quantile algorithmPCTLDEF=5quantile type=7The default algorithms differ.
SAS-default-compatible quantile algorithmPCTLDEF=5quantile type=2R documents type 2 as the SAS default counterpart.
Maximum sample size for Shapiro-Wilk20005000Compare nonmissing sample size with the limit documented for each implementation.

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about PROC UNIVARIATE SAS: Syntax and Output

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →