Subsetting Data Using Subqueries
Introducing Subqueries
A Brief Overview
A subquery selects rows from one table based on values
in another table. Subqueries are also known as nested
queries or inner queries.
A subquery is a query expression that is
nested as part of another query expression. Depending on the clause
that contains it, a subquery can return a single value or multiple
values. Subqueries are most often used in WHERE and HAVING clauses.
Subqueries are enclosed in parentheses.
The following PROC SQL
query contains a subquery in the HAVING clause that returns all jobcodes
where the average salary for that jobcode is greater than the company
average salary.
proc sql; select jobcode, avg(salary) as AvgSalary format=dollar11.2 from ...
Get SAS Certified Professional Prep Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.