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

STD Function in SAS: Standard Deviation in SAS Explained

How the SAS STD function and PROC MEANS compute standard deviation, with documented examples, VARDEF rules and troubleshooting.

Written and maintained by CASRAI Editorial Board

Published

On this page

In SAS, “STD” is the standard deviation: the STD function returns the sample standard deviation of its nonmissing arguments, and STD is also a statistic keyword in procedures such as PROC MEANS. This guide is for researchers who need to compute, interpret and troubleshoot standard deviation in SAS. It is not about sexually transmitted diseases, which is a different use of the same abbreviation.

What the STD function does in SAS research code

According to the SAS 9.3 Functions and CALL Routines reference, STD(argument-1, argument-2 <,...argument-n>) belongs to the Descriptive Statistics category and “returns the standard deviation of the nonmissing arguments.” Each argument can be a constant, variable or expression. At least two nonmissing arguments are required; otherwise the function returns a missing value. Arguments can also be given as a variable list preceded by OF.

The key conceptual point is direction. The STD function works across variables within one observation (row). PROC MEANS works down the observations (column) for each variable. Mixing these up is the most common reason a reported standard deviation looks wrong.

Tool Direction What it returns
STD(...) function in a DATA step Across the arguments in one row Standard deviation of the nonmissing arguments; missing if fewer than two
PROC MEANS STD (or STDDEV) keyword Down the observations of each analysis variable Sample standard deviation, the square root of the variance
PROC MEANS STDERR keyword Down the observations Standard error of the mean; computed only when VARDEF=DF (the default), otherwise missing
PROC IML and FedSQL STD Per column / aggregate Separate implementations documented on their own SAS pages; not the same as the DATA step function

The standard deviation describes spread in your data. The standard error describes uncertainty of the mean; do not report one when you mean the other. For the spreadsheet equivalents of these ideas, see Excel statistics functions, and for the difference between population and sample variance see how to find population variance.

Access SAS

Use SAS from your institution, or use SAS OnDemand for Academics, which SAS describes as a free cloud-based learning environment for students, educators and independent learners. You sign up through the “Access now” option at welcome.oda.sas.com and need a SAS profile. It includes SAS Studio, a browser-based interface for writing programs, and SAS Enterprise Guide, a point-and-click interface. See the SAS page listed under Sources for current terms.

Step-by-step: STD function and PROC MEANS

Row-wise standard deviation with the STD function

  1. Open a program editor (for example, SAS Studio).
  2. Write a DATA step that calls the function. These are the documentation’s own examples:
    data _null_;
      x1 = std(2,6);
      x2 = std(2,6,.);
      x3 = std(2,4,6,3,1);
      x4 = std(of x1-x3);
      put x1= x2= x3= x4=;
    run;
  3. Run the step and read the log. The documentation shows x1 as 2.8284271247, x3 as 1.9235384062 and x4 as 0.5224377453. The x2 call includes a missing value, which is ignored because only nonmissing arguments are used.
  4. For your own data, list the variables, for example sd_score = std(of q1-q10);, to get a per-participant standard deviation across q1 to q10.

Column-wise standard deviation with PROC MEANS

  1. Run proc means data=mydata; var score; run;, replacing the data set and variable names with yours.
  2. With no statistics keywords, PROC MEANS reports N, mean, standard deviation, minimum and maximum (also documented in Penn State’s STAT 480 course notes).
  3. To request specific statistics, name them, for example proc means data=mydata n mean std stderr; var score; run;. Naming keywords replaces the default list, so include every statistic you want.
  4. Add a class or by statement to get a standard deviation per group.

Output and how to read it

PROC MEANS prints one row per analysis variable (or per group) with the statistics you requested. The structure is: variable name, N, mean, standard deviation, minimum and maximum. Read the standard deviation next to the mean: it is in the same units as the variable. The STD function writes its result to a variable in the data set (or the log with put), so check it row by row. For reporting conventions, see APA statistics reporting.

Troubleshooting

The result is missing

The STD function needs at least two nonmissing arguments. A row with one valid value, or none, returns a missing value by design.

STD and STDERR give different numbers

They measure different things: STDERR is the standard error of the mean, which is smaller than the standard deviation when n is greater than one. Confirm which keyword you requested.

Divisor and VARDEF

PROC MEANS uses VARDEF= to set the variance divisor; the default is DF (degrees of freedom). STDERR, CLM, LCLM, UCLM, T and PRT require VARDEF=DF; with another setting those statistics are missing.

Free alternatives

Tool Standard deviation Note
R sd() Sample standard deviation
Python (NumPy) numpy.std See NumPy std for the divisor setting
SAS OnDemand for Academics Same SAS code as above Free learning environment from SAS

For a comparison of R and SAS as research tools, see R vs SAS.

FAQ

What is SAS used for in statistics?

SAS is a statistical analysis software environment used for data management, descriptive statistics, modelling and reporting. Its functions and procedures, such as STD and PROC MEANS, cover descriptive statistics. See SAS statistical software and ANOVA in SAS.

Is SAS still relevant in 2026?

SAS remains in use in teaching and in analysis workflows that already rely on it, and SAS offers a free learning environment. Whether it fits your project depends on the tools your institution supports; the overview is in SAS statistical software.

Is SAS similar to Python?

Both can compute the same descriptive statistics, but the style differs: SAS uses DATA steps and procedures, Python uses libraries such as NumPy. Check the divisor each tool uses before comparing results.

What does SAS mean in jobs?

In analytics job postings, SAS normally refers to this statistical software and the programming skills used with it. It is unrelated to other uses of the abbreviation.

Sources

Follow CASRAI

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

Ask CASRAI · free to try

Ask about STD Function in SAS: Standard Deviation in SAS Explained

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

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 free 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 →