Browse Prior Art Database

SAS 9.2 SQL Procedure User's Guide Disclosure Number: IPCOM000244109D
Original Publication Date: 2009-Dec-31
Included in the Prior Art Database: 2015-Nov-09
Document File: 196 page(s) / 2M

Publishing Venue

SAS Institute Inc.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 4% of the total text.

Page 01 of 196

SAS® 9.2 SQL Procedure

User's Guide

SAS® Documentation

Page 02 of 196

The correct bibliographic citation for this manual is as follows: SAS Institute Inc., SAS ®
9.2 SQL Procedure User's Guide. Cary, NC: SAS Institute Inc., 2009.

SAS® 9.2 SQL Procedure User's Guide

Copyright © 2009, SAS Institute Inc., Cary, NC, USA.

ISBN 978-1-599944-853-9
All rights reserved. Produced in the United States of America.

For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc.

For a Web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication.

U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19 Commercial Computer Software-Restricted Rights (June 1987).

SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
1st electronic book, February 2009
1st printing, February 2009
SAS® Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit the SAS Publishing Web site at or call 1-800-727-3228.

SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are registered trademarks or trademarks of their respective companies.

Page 03 of 196

4 Introduction to the SQL Procedure 1

What Is SQL? 1

What Is the SQL Procedure? 1
Terminology 2
Comparing PROC SQL with the SAS DATA Step 3 Notes about the Example Tables 5

Chapter 2

4 Retrieving Data from a Single Table 11

Overview of the SELECT Statement 12
Selecting Columns in a Table 14
Creating New Columns 18
Sorting Data 25
Retrieving Rows That Satisfy a Condition 31 Summarizing Data 40
Grouping Data 47
Filtering Grouped Data 51
Validating a Query 53

Chapter 3

4 Retrieving Data from Multiple Tables 55

Introduction 56
Selecting Data from More Than One Table by Using Joins 56 Using Subqueries to Select Data 74
When to Use Joins and Subqueries 80
Combining Queries with Set Operators 81

Chapter 4

      4 Creating and Updating Tables and Views 89 Introduction 90
Creating Tables 90
Inserting Rows into Tables 93
Updating Data Values in a Table 96
Deleting Rows 98
Altering Columns 99
Creating an Index 102
Deleting a Table 103
Using SQL Procedure Tables in SAS Software 103 Creating and Using Integrity Constraints in a Table 103 Creating and Using PROC SQL Views 106

Chapter 5

4 Programming with the SQL Procedure 11...