Written and maintained by CASRAI Editorial Board
Published
On this page
PROC SUMMARY in SAS computes descriptive statistics for numeric variables, either across the whole data set or within groups defined by CLASS variables, and its usual job is to write those statistics to a new SAS data set through the OUTPUT statement. SAS’s documentation states that, except for the differences it lists, everything documented for PROC MEANS also applies to PROC SUMMARY, so the two procedures share one syntax and one set of statistics. The practical habit to take away is simple: use PROC SUMMARY when the result is a data set you will analyse, merge or report from, not a table you only want to look at.
What PROC SUMMARY in SAS is used for in research
Research data sets are rarely analysed at the level they are collected. Trial visits, survey responses or instrument readings usually need to be reduced to one row per site, arm, wave or participant before modelling or reporting. PROC SUMMARY does that reduction. You name the grouping variables in a CLASS statement, the numeric variables in a VAR statement, and the statistics you want in an OUTPUT statement; SAS returns a compact data set that carries one row per group.
Because the result is an ordinary SAS data set, it can feed the next step of an analysis: a merge back onto the detail records, a table-building step, a plot, or a check against a published figure. This is what separates it from reading a printed table: the summary is reproducible, machine-readable and easy to audit. For the descriptive-versus-inferential distinction that underlies this kind of summarising, see descriptive statistics versus inferential statistics.
SAS PROC SUMMARY and PROC MEANS: what differs
The SAS 9.4 documentation for the SUMMARY procedure says it is very similar to the MEANS procedure and that all the PROC MEANS information also applies to PROC SUMMARY except for the differences described on that page. The difference it lists is variable type: the VARCHAR variable type is not supported in PROC SUMMARY. The other difference that matters day to day is the default display. The PROC MEANS documentation states that PRINT is the default and that NOPRINT suppresses all displayed output. The SAS 8 documentation for PROC SUMMARY says that by default PROC SUMMARY does not display output. In practice that means a PROC SUMMARY step with an OUTPUT statement creates a data set quietly, while an equivalent PROC MEANS step prints a table unless you add NOPRINT.
The default statistics are shared: with no statistic keywords, the MEANS documentation says N, MEAN, STD, MIN and MAX are computed. If you work with the variants “proc summary in sas” and “sas proc summary”, they all refer to this one procedure.
How to access SAS to run PROC SUMMARY
PROC SUMMARY is part of Base SAS, so any SAS session that can run a DATA step can run it. SAS publishes a free, cloud-based learning environment, SAS OnDemand for Academics, on its own site. SAS’s page says you create a SAS profile and log in; if your class is registered, your instructor supplies a code to register, and learners who are not taking a class can still get free access to the SAS Studio version. The same page describes two interfaces: SAS Studio, a web-browser interface for writing SAS programs and working with data, and SAS Enterprise Guide, a point-and-click, menu- and wizard-driven interface. It also lists up to 5 GB of cloud storage per user.
If you prefer a point-and-click route, our guide to SAS Enterprise Guide explains that interface. The PROC SUMMARY statements in this guide are ordinary SAS program code, so they are written the same way whichever interface you use.
How to run PROC SUMMARY in SAS step by step
The example below uses invented names (a data set work.trial with class variables site and arm and a numeric variable sbp) purely to show the syntax; substitute your own. The statements and options are those documented for PROC MEANS, which applies to PROC SUMMARY.
-
Name the input and the options. Start with
proc summary data=work.trial nway;. DATA= identifies the input data set. NWAY limits the output data set to the observations with the highest _TYPE_ and _WAY_ values, which with class variables is the combination of all of them. -
Add a CLASS statement.
class site arm;groups the analysis by those variables. By default, observations with a missing class value are excluded; add the MISSING option to the PROC statement if missing values should count as their own level. -
Name the analysis variable.
var sbp;lists the numeric variable to summarise. -
Request statistics in OUTPUT.
output out=work.sbp_summary mean=mean_sbp std=sd_sbp n=n_sbp;creates the data set named in OUT= and stores each requested statistic under the name you give it. This keyword=name pattern is the one SAS’s own PROC MEANS example uses, wheremean=AverageGradewrites the mean of the analysis variable to a variable called AverageGrade. -
Close the step. End with
run;. -
Look at the result. Because the SAS 8 documentation says PROC SUMMARY does not display output by default, print the new data set:
proc print data=work.sbp_summary; run;.
The complete program reads:
proc summary data=work.trial nway;
class site arm;
var sbp;
output out=work.sbp_summary mean=mean_sbp std=sd_sbp n=n_sbp;
run;
proc print data=work.sbp_summary;
run;
Which option answers which question
| You want | Use | What the documentation says |
|---|---|---|
| Only the finest-grained groups (every site by arm combination) | NWAY on the PROC statement | Keeps the observations with the highest _TYPE_ and _WAY_ values, which with class variables is the combination of all of them; it is ignored if you use a TYPES or WAYS statement. |
| The overall total alongside the groups | Omit NWAY | The overall total is the observation with _TYPE_=0, which the DESCENDTYPES option moves to the end of each BY group. |
| Groups whose class value is missing | MISSING | Treats missing values as valid levels; each special missing value (A to Z and the underscore) counts as a separate level. |
| A printed table as well as a data set | PRINT on the PROC statement, or use PROC MEANS | PRINT is the PROC MEANS default and NOPRINT suppresses all displayed output. |
| Which class variables were combined in each row | _TYPE_ and _WAY_ in the output | _TYPE_ identifies the level of class-variable combination; _WAY_ stores the number of class variables combined. |
The data table below the guide lists these options and output variables with the documentation each one comes from.
How to read the PROC SUMMARY output
The output data set contains the CLASS variables, the statistics you named in the OUTPUT statement, and automatic variables that describe how each row was formed. Three matter for research use.
_TYPE_ and _WAY_
_TYPE_ identifies the level of class-variable combination for each observation, and _WAY_ stores how many class variables were combined. The MEANS documentation states that _TYPE_ is numeric unless you request CHARTYPE, which stores it as a character string, and that it becomes character automatically with more than 32 class variables. Without NWAY, a data set with CLASS variables holds the overall row (_TYPE_=0) as well as the grouped rows, so a downstream step that assumes one row per group should either use NWAY or filter on _TYPE_.
_FREQ_
_FREQ_ corresponds to the “N Obs” column in printed MEANS output, as the MEANS documentation puts it. It is the count of observations contributing to the row, which is not the same thing as the N statistic when the analysis variable has missing values. If you need both the number of records and the number of non-missing values, keep _FREQ_ and request N explicitly as in the example.
Checking the result
Print the data set, then compare one group against a hand calculation or a PROC SQL query on the detail table. Our PROC SQL guide shows how to produce group summaries in SQL, which makes a useful independent check, and PROC CONTENTS lets you confirm that the variable names and types in the output data set are what you expected before you merge it onto anything. For distribution detail beyond the standard statistics, see PROC UNIVARIATE in SAS.
Troubleshooting PROC SUMMARY in SAS
- Nothing prints. That is expected: the SAS 8 documentation says PROC SUMMARY does not display output by default. Read the output data set with PROC PRINT, or run the same statements under PROC MEANS if you want the table on screen.
- The output has extra rows. You asked for CLASS variables without NWAY, so the data set holds every combination level, including the overall total. Add NWAY, or filter on _TYPE_ or _WAY_. Note that NWAY has no effect if there are no CLASS variables and is ignored if you use a TYPES or WAYS statement.
- Some participants or sites are missing from the output. Observations with a missing class value are excluded by default. Add MISSING to the PROC statement if they should form their own level.
- A character variable is not accepted as a summary variable. The documentation states that the VARCHAR type is not supported in PROC SUMMARY. Check the types with PROC CONTENTS.
- The statistics are not the ones you expected. With no statistic keywords the default is N, MEAN, STD, MIN and MAX. Name the statistics you want in the OUTPUT statement.
Free alternatives to PROC SUMMARY
If you do not have SAS, grouped summaries are a core operation in open-source tools. The table maps the PROC SUMMARY pattern to the documented equivalent in each, using the documentation examples each project publishes.
| Tool | Equivalent of CLASS, VAR and OUTPUT | Documented behaviour |
|---|---|---|
| Python with pandas | df.groupby("kind").agg(...) |
groupby splits the data into groups on one or more keys, applies a function to each and combines the results; named aggregation takes (column, function) pairs, so each keyword is an output column name. |
| R with dplyr | group_by(cyl) followed by summarise(mean = mean(disp), n = n()) |
summarise() returns one row for each combination of grouping variables. |
| SAS PROC MEANS | proc means ... noprint; with the same CLASS, VAR and OUTPUT statements |
The same procedure family: SUMMARY documentation points to PROC MEANS for the full syntax. |
For the R route, our guide to the summary function in R covers the related base-R tooling.
Sources
- SAS 9.4 Base SAS Procedures Guide: SUMMARY Procedure, read 2026-11-17.
- SAS Base SAS 9.3 Procedures Guide: MEANS Procedure, read 2026-11-17.
- SAS Base SAS 9.3 Procedures Guide: MEANS procedure example with CLASS, VAR and OUTPUT, read 2026-11-17.
- SAS 8 documentation, The SUMMARY Procedure (hosted by Simon Fraser University), read 2026-11-17.
- SAS OnDemand for Academics, read 2026-11-17.
- pandas user guide: Group by, split-apply-combine, read 2026-11-17.
- dplyr reference: summarise(), read 2026-11-17.
Data: PROC MEANS and PROC SUMMARY options and output variables, as documented by SAS
Options and automatic output variables shared by PROC MEANS and PROC SUMMARY, with the effect each has as stated in SAS documentation pages for the MEANS and SUMMARY procedures.
| Option or variable | Where it appears | Documented effect | Source |
|---|---|---|---|
| NWAY | PROC statement option | Limits the output data set to observations with the highest _TYPE_ and _WAY_ values; ignored with a TYPES or WAYS statement | SAS MEANS Procedure (9.3) |
| PRINT | NOPRINT | PROC statement option | PRINT is the PROC MEANS default; NOPRINT suppresses all displayed output | SAS MEANS Procedure (9.3) |
| MISSING | CLASS-related option | Treats missing class values as valid levels instead of excluding the observation; special missing values A-Z and _ are separate levels | SAS MEANS Procedure (9.3) |
| DESCENDTYPES | PROC statement option | Sorts by descending _TYPE_ so the overall total (_TYPE_=0) appears last in each BY group | SAS MEANS Procedure (9.3) |
| CHARTYPE | PROC statement option | Stores _TYPE_ as a character string; _TYPE_ becomes character automatically with more than 32 class variables | SAS MEANS Procedure (9.3) |
| _TYPE_ | Output variable | Identifies the level of class-variable combination for the observation | SAS MEANS Procedure (9.3) |
| _WAY_ | Output variable | Stores the number of class variables combined in the observation | SAS MEANS example (9.3) |
| _FREQ_ | Output variable | Corresponds to the N Obs column in printed output | SAS MEANS Procedure (9.3) |
| VARCHAR variables | Variable type | Not supported in PROC SUMMARY | SAS 9.4 SUMMARY Procedure |
| Default display | PROC SUMMARY (SAS 8 text) | By default, PROC SUMMARY does not display output | SAS 8 SUMMARY Procedure |
Sources
- SAS Base SAS 9.3 Procedures Guide: MEANS Procedure (accessed 2026-11-17)
- SAS Base SAS 9.3 Procedures Guide: MEANS procedure example (accessed 2026-11-17)
- SAS 9.4 SUMMARY Procedure (accessed 2026-11-17)
- SAS 8 documentation: The SUMMARY Procedure (accessed 2026-11-17)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







