Performing Queries Using SQL |
Lesson
Summary |
This page contains
|
I. Text Summary
To go to the page where a task, programming feature, or concept was presented, select a link. |
PROC SQL Basics PROC SQL uses statements written in Structured Query Language, or SQL, a standardized language that is widely used to retrieve and update data in tables and views based on those tables. When you want to examine relationships between data values, subset your data, or compute values, the SQL procedure provides an easy, flexible way to analyze your data. |
Writing a PROC SQL Step Before creating a query, you must assign a libref to the SAS data library that stores the table to be used. Then you submit a PROC SQL step. You invoke the SQL procedure using the PROC SQL statement. |
The SELECT Statement After you invoke the SQL procedure, the SELECT statement performs the tasks of retrieving and displaying data. It is composed of clauses, including the |
Querying Multiple Tables You can use a PROC SQL step to query data stored in two or more tables. In SQL terminology, this is called "joining" tables. To join multiple tables
|
Ending the SQL Procedure PROC SQL is an interactive procedure. A status line in the Program Editor window, "PROC SQL running," informs you that the procedure is active. To end the SQL procedure, you can submit
|
|
II. Syntax
To go to the page where a statement or option was presented, select a link. |
LIBNAME libref 'SAS-data-library'; |
PROC SQL; |
SELECT column-1 <, . . . column-n,> |
<WHERE expression> |
<ORDER BY column-1 <, . . . column-n,>>; |
|
III. Sample Programs
proc sql; select id,lastname,netpay,grosspay, grosspay*.06 as bonus from emplib.payroll where netpay>25000 order by lastname; quit;
|
IV. Points to Remember
|
|
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.