Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
Proc SQL [11-14]


Summary Functions
SELECT gender,
  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:
Picture

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:
Picture

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.
Next

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.
Already a member? Go to member's area.