Sentry Page Protection

**Proc SQL [11-14]**

**Summary Functions**

mean(height) AS mean,

var(height) AS var,

min(height) AS min,

max(heightn) AS max

FROM school

GROUOP BY gender;

Below is the list of summary functions that can be used to summarize data:

- AVG/MEAN
- COUNT/FREQ
- CSS
- CV
- MAX
- MIN
- NMISS
- PRT
- RANGE
- STD
- STDERR
- SUM
- T
- USS
- VAR

Let's take a look at an example.

Copy and run the

**SCHOOL**table from the yellow box below if you haven't done so.

__Example__**Proc sql;**

select

mean(height) as mean,

var(height) as var,

min(height) as min,

max(height) as max,

sum(height) as sum,

nmiss(height) as nm

from school;

**quit;**

The summary functions compute the corresponding statistics for the HEIGHT column:

**GROUP BY Clause**

Again, you can group the analysis using the GROUP BY clause.

__Example__

**Proc sql;**

select

gender,

mean(height) as mean,

var(height) as var,

min(height) as min,

max(height) as max,

sum(height) as sum,

nmiss(height) as nm

from school

group by gender;

**quit;**

The statistics are computed for the two genders:

**Exercise**

Locate the CARS table from the SASHelp library.

Write a Proc SQL step to compute the mean, minimum, maximum and standard deviation of the HORSEPOWER column for each of the car makers.

*Need some help?*

**HINT: **

Use the MEAN, STD, MIN and MAX functions to compute the required statistics.

**SOLUTION: **

Proc sql;

select

make,

mean(horsepower) as mean,

std(horsepower) as std,

min(horsepower) as min,

max(horsepower) as max

from sashelp.cars

group by make;

quit;

Fill out my online form.