group by Continent
having Continent in ('Asia', 'Europe')
order by Continent;
Ordering the SELECT Statement
When you construct a SELECT statement, you must specify the clauses in the following
4. GROUP BY
6. ORDER BY
Note: Only the SELECT and FROM clauses are required.
The PROC SQL SELECT statement and its clauses are discussed in further detail in the
Selecting Columns in a Table
When you retrieve data from a table, you can select one or more columns by using
variations of the basic SELECT statement.
Selecting All Columns in a Table
Use an asterisk in the SELECT clause to select all columns in a table. The following
example selects all columns in the Sql.USCityCoords table, which contains latitude and
longitude values for U.S. cities:
libname sql 'SAS-library';
proc sql outobs=12;
title 'U.S. Cities with Their States and Coordinates';
Note: The OUTOBS= option limits the number of rows (observations) in the output.
OUTOBS= is similar to the OBS= data set option. OUTOBS= is used throughout
this document to limit the number of rows that are displayed in examples.
Note: In the tables used in these examples, latitude values that are south of the Equator
are negative. Longitude values that are west of the Prime Meridian are also negative.
22 Chapter 2 • Retrieving Data from a Single Table