![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS SQL Query Window User's Guide |
The Having condition specifies the condition(s) that each group must satisfy in order to be included in the query output. You can use a Having condition to subset grouped data by using HAVING in the same query with a GROUPBY and a summary function.
Which divisions in the previous example have a minimum education level that is greater than 15 years?
To find out, remove
LOCATION from the Selected Columns
list in the SQL QUERY COLUMNS window. Remove duplicate values by selecting
| View | ![]() |
Distinct |
| Having Expression Window |
To create a condition that each group must satisfy, select
| View | ![]() |
Having Condition for Group... |
to display the HAVING EXPRESSION window.
Select
Summary Functions. Select
MIN from the list of summary
functions.
Select
Education level from the list of Available Columns.
Select
GT from the list of operators that appears.
Select
<CONSTANT enter value> from the list of Available
Columns. The Numeric Values window appears.
Type 15 in the Numeric Values window and
select
OK.
In the HAVING EXPRESSION window, select
OK to return to the SQL
QUERY COLUMNS window.
| Viewing the Results of the HAVING Condition |
Select
| View | ![]() |
Group(s) for Summary Functions... |
to display the GROUP BY COLUMNS window.
Select
DIVISION from the list of Available Columns and add
it to the list of Group By Columns.
Select
OK.
Select
| Tools | ![]() |
Run Immediate |
to display the divisions whose minimum employee education level is greater than 15.
Select
| Tools | ![]() |
Reset |
to reset the query and return to the SQL QUERY TABLES window.
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.