Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu SAS 9.1 SQL Procedure- P1 docx
Nội dung xem thử
Mô tả chi tiết
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
SAS®
9.1 SQL Procedure
User’s Guide
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
The correct bibliographic citation for this manual is as follows: SAS Institute Inc., 2004.
SAS ® 9.1 SQL Procedure User’s Guide. Cary, NC: SAS Institute Inc.
SAS® 9.1 SQL Procedure User’s Guide
Copyright © 2004, SAS Institute Inc., Cary, NC, USA.
ISBN 1-59047-334-5
All rights reserved. Produced in the United States of America. 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.
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 printing, January 2004
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 support.sas.com/publishing 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.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Contents
Chapter 1 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 4
Chapter 2 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 30
Summarizing Data 39
Grouping Data 45
Filtering Grouped Data 50
Validating a Query 52
Chapter 3 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 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 105
Chapter 5 Programming with the SQL Procedure 111
Introduction 111
Using PROC SQL Options to Create and Debug Queries 112
Improving Query Performance 115
Please purchase PDF Split-Merge on www.verypdf.com to remove this water
iv
Accessing SAS System Information Using DICTIONARY Tables 117
Using PROC SQL with the SAS Macro Facility 120
Formatting PROC SQL Output Using the REPORT Procedure 127
Accessing a DBMS with SAS/ACCESS Software 128
Using the Output Delivery System (ODS) with PROC SQL 132
Chapter 6 Practical Problem-Solving with PROC SQL 133
Overview 134
Computing a Weighted Average 134
Comparing Tables 136
Overlaying Missing Data Values 138
Computing Percentages within Subtotals 140
Counting Duplicate Rows in a Table 141
Expanding Hierarchical Data in a Table 143
Summarizing Data in Multiple Columns 144
Creating a Summary Report 146
Creating a Customized Sort Order 148
Conditionally Updating a Table 150
Updating a Table with Values from Another Table 153
Creating and Using Macro Variables 154
Using PROC SQL Tables in Other SAS Procedures 157
Appendix 1 Recommended Reading 161
Recommended Reading 161
Glossary 163
Index 167
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermar