Table of Contents
Proc Summary is a powerful tool in SAS that allows users to efficiently summarize and analyze data. It is used to calculate descriptive statistics such as mean, median, minimum, maximum, and standard deviation for numeric variables. Additionally, it can also be used to create frequency tables, as well as perform grouping and sorting of data. To use Proc Summary, users need to specify the data set, the variables to be summarized, and the desired statistics to be calculated. For example, to calculate the mean and standard deviation of a variable called “age” in a data set called “patients”, the syntax would be “proc summary data = patients mean std; var age; run;”. This would generate a table with the mean and standard deviation values for the “age” variable. Overall, Proc Summary is a useful tool for quickly summarizing and analyzing data in SAS.
Use Proc Summary in SAS (With Examples)
You can use proc summary in SAS to quickly calculate the following for one or more variables in a dataset:
- N: The total number of observations
- MIN: The minimum value
- MAX: The maximum value
- MEAN: The mean
- STD: The standard deviation
The following examples show how to use this procedure with the SAS built-in dataset called , which contains various measurements for 159 different fish caught in a lake in Finland.
We can use proc print to view the first 10 from this dataset:
/*view first 10 observations from Fish dataset*/ proc printdata=sashelp.Fish (obs=10); run;

Related:
Example 1: Proc Summary with One Variable
We can use the following code to calculate descriptive statistics for the Weight variable:
/*calculate descriptive statistics for Weight variable*/
proc summarydata=sashelp.Fish;
var Weight;
output out=summaryWeight;
run;
/*print output dataset*/
proc printdata=summaryWeight;
Here’s how to interpret the output table:
- _TYPE_: This column shows whether or not every row in the dataset was used to calculate the descriptive statistics. 0 = Every row was used.
- _FREQ_: The number of rows used to calculate each descriptive statistic.
- _STAT_: The name of the descriptive statistic.
- Weight: The numerical value for the corresponding descriptive statistic.
From the output we can see:
- The total number of observations was 158.
- The minimum weight value was 0.
- The maximum weight value was 1,650.
- The mean weight value was 398.70.
- The standard deviation of weight values was 359.09.
From these five values we can gain a pretty good understanding of the distribution of values for the Weight variable.
Example 2: Proc Summary with Multiple Variables
For example, we can use the following code to calculate descriptive statistics for the Weight and Height variables:
/*calculate descriptive statistics for Weight and Height variables*/
proc summarydata=sashelp.Fish;
var WeightHeight;
output out=summaryWeightHeight;
run;
/*print output dataset*/
proc printdata=summaryWeightHeight;
From the output we can see the five descriptive statistics for both Weight and Height.
Example 3: Proc Summary with One Variable Grouped by Another Variable
To calculate descriptive statistics for one variable grouped by another variable, we can use the class statement.
For example, we can use the following code to calculate descriptive statistics for Weight grouped by Species:
/*calculate descriptive statistics for Weight grouped by Species*/
proc summarydata=sashelp.Fish;
var Weight;
class Species;
output out=summaryWeightSpecies;
run;
/*print output dataset*/
proc printdata=summaryWeightSpecies;
The output table displays the descriptive statistics for each Species of fish.
For example, we can observe the following descriptive statistics for just the Bream fish:
- The total number of observations was 34.
- The minimum weight value was 242.
- The maximum weight value was 1,000.
- The mean weight value was 626.
- The standard deviation of weight values was 206.60.
We can observe these descriptive statistics for every other species as well.
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
stats writer (2024). How to use Proc Summary in SAS with examples?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-use-proc-summary-in-sas-with-examples/
stats writer. "How to use Proc Summary in SAS with examples?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-to-use-proc-summary-in-sas-with-examples/.
stats writer. "How to use Proc Summary in SAS with examples?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-to-use-proc-summary-in-sas-with-examples/.
stats writer (2024) 'How to use Proc Summary in SAS with examples?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-use-proc-summary-in-sas-with-examples/.
[1] stats writer, "How to use Proc Summary in SAS with examples?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How to use Proc Summary in SAS with examples?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
