STAT 475
Chapter 1
PERFORMING QUERIES USING PROC SQL
Reference
SAS Certification Prep Guide: Advanced Programming for SAS 9
PROC SQL
step provides an efficient way to retrieve information from data sets. The
abbreviation SQL stands for
Structured Query Language
. There are several
statements that can be used with the PROC SQL step. We will study the
SELECT
statement
. A PROC SQL step that contains one or more SELECT statements is called a
PROC SQL query
.
THE SELECT STATEMENT
The syntax is as follows:
PROC SQL;
SELECT
variable1
,
variable2
,
…
<
as
newvariable>
FROM
dataset1 dataset2 …
WHERE
expression
GROUP BY
variable1 variable2
…;
ORDER BY
variablename1 variablename2 …
;
QUIT;
SELECT specifies column(s) to be selected
FROM specifies table(s) to be queried
WHERE subsets the data based on the specified expression
GROUP BY
groups data by specified variable(s)
ORDER BY classifies the data into groups based on the specified column(s)
•
The SELECT is a statement is composed of
clauses
: FROM, WHERE, GROUP BY,
ORDER BY.
These clauses must appear in the specified order.
•
Date sets listed under the FROM clause are referred to as
tables
.
1
This
preview
has intentionally blurred sections.
Sign up to view the full version.
•
To terminate PROC SQL, the
QUIT
statement must be specified.
Example.
Class roster contains students’ names, IDs, scores on the final, total scores and
letter grades. The following code uses PROC SQL to select the students with passing

This is the end of the preview.
Sign up
to
access the rest of the document.
- Fall '11
- OlgaK
- PostgreSQL, proc sql, PTID
-
Click to edit the document details