Chapter Contents


The SQL Procedure


The SQL procedure implements Structured Query Language (SQL) for the SAS System. SQL is a standardized, widely used language that retrieves and updates data in tables and views based on those tables.

The SAS System's SQL procedure enables you to

PROC SQL Input and Output summarizes the variety of source material that you can use with PROC SQL and what the procedure can produce.

PROC SQL Input and Output


What Are PROC SQL Tables?
A PROC SQL table is synonymous with a SAS data file and has a member type of DATA. You can use PROC SQL tables as input into DATA steps and procedures.

You create PROC SQL tables from SAS data files, from SAS data views, or from DBMS tables using PROC SQL's Pass-Through Facility. The Pass-Through Facility is described in Connecting to a DBMS Using the SQL Procedure Pass-Through Facility .

In PROC SQL terminology, a row in a table is the same as an observation in a SAS data file. A column is the same as a variable.

What Are Views?
A SAS data view defines a virtual data set that is named and stored for later use. A view contains no data but describes or defines data that are stored elsewhere. There are three types of SAS data views:

You can refer to views in queries as if they were tables. The view derives its data from the tables or views that are listed in its FROM clause. The data accessed by a view are a subset or superset of the data in its underlying table(s) or view(s).

A PROC SQL view is a SAS data set of type VIEW created by PROC SQL. A PROC SQL view contains no data. It is a stored query expression that reads data values from its underlying files, which can include SAS data files, SAS/ACCESS views, DATA step views, other PROC SQL views, or DBMS data. When executed, a PROC SQL view's output can be a subset or superset of one or more underlying files.

SAS/ACCESS views and DATA step views are similar to PROC SQL views in that they are both stored programs of member type VIEW. SAS/ACCESS views describe data in DBMS tables from other software vendors. DATA step views are stored DATA step programs.

You can update data through a PROC SQL or SAS/ACCESS view with certain restrictions. See Updating PROC SQL and SAS/ACCESS Views .

You can use all types of views as input to DATA steps and procedures.

Note:   In this chapter, the term view collectively refers to PROC SQL views, DATA step views, and SAS/ACCESS views, unless otherwise noted.  [cautionend]

SQL Procedure Coding Conventions
Because PROC SQL implements Structured Query Language, it works somewhat differently from other base SAS procedures, as described here:

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.