SAS
®
Programming I:
Essentials
Course Notes
SAS
®
Programming I: Essentials Course Notes was developed by Michelle Buchecker, Sarah Calhoun,
and Larry Stewart. Additional contributions were made by Warren Repole. Editing and production
support was provided by the Curriculum Development and Support Department.
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 trademarks of their respective companies.
SAS
®
Programming I: Essentials Course Notes
Copyright
2004 by SAS Institute Inc., Cary, NC 27513, USA. All rights reserved. Printed 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.
Book code 59728, course code PROG1, prepared date 29Apr04.
For Your Information iii
Table of Contents
Course Description...................................................................................................................... vi
To learn more…..........................................................................................................................vii
Prerequisites ..............................................................................................................................viii
General Conventions ................................................................................................................... ix
Chapter 1 Introduction .......................................................................................... 1-1
1.1 An Overview of the SAS System.....................................................................................1-3
Chapter 2 Getting Started with the SAS
®
System ............................................... 2-1
2.1 Introduction to SAS Programs.........................................................................................2-3
2.2 Running SAS Programs ...................................................................................................2-8
2.3 Mastering Fundamental Concepts..................................................................................2-31
2.4 Diagnosing and Correcting Syntax Errors .....................................................................2-41
2.5 Exploring Your SAS Environment (Self-Study)............................................................2-52
2.6 Solutions to Exercises....................................................................................................2-67
Chapter 3 Getting Familiar with SAS
®
Data Sets................................................. 3-1
3.1 SAS Data Libraries ..........................................................................................................3-3
3.2 Solutions to Exercises....................................................................................................3-16
Chapter 4 Producing List Reports........................................................................ 4-1
4.1 Getting Started with the PRINT Procedure......................................................................4-3
4.2 Sequencing and Grouping Observations........................................................................4-14
4.3 Identifying Observations (Self-Study)...........................................................................4-22
4.4 Special WHERE Statement Operators (Self-Study) ......................................................4-28
iv For Your Information
4.5 Solutions to Exercises....................................................................................................4-31
Chapter 5 Enhancing Output ................................................................................ 5-1
5.1 Customizing Report Appearance .....................................................................................5-3
5.2 Formatting Data Values....................................................................................................5-8
5.3 Creating HTML Reports ................................................................................................5-23
5.4 Solutions to Exercises....................................................................................................5-29
Chapter 6 Creating SAS
®
Data Sets...................................................................... 6-1
6.1 Reading Raw Data Files: Column Input ..........................................................................6-3
6.2 Reading Raw Data Files: Formatted Input.....................................................................6-20
6.3 Examining Data Errors ..................................................................................................6-30
6.4 Assigning Variable Attributes ........................................................................................6-40
6.5 Changing Variable Attributes (Self-Study) ....................................................................6-47
6.6 Reading Excel Spreadsheets (Self-Study)......................................................................6-62
6.7 Solutions to Exercises....................................................................................................6-77
Chapter 7 DATA Step Programming ..................................................................... 7-1
7.1 Reading SAS Data Sets and Creating Variables ..............................................................7-3
7.2 Conditional Processing ..................................................................................................7-16
7.3 Dropping and Keeping Variables (Self-Study) ..............................................................7-32
7.4 Reading Excel Spreadsheets Containing Date Fields (Self-Study)................................7-35
7.5 Solutions to Exercises....................................................................................................7-40
Chapter 8 Combining SAS
®
Data Sets ................................................................. 8-1
8.1 Concatenating SAS Data Sets..........................................................................................8-3
8.2 Merging SAS Data Sets .................................................................................................8-14
For Your Information v
8.3 Combining SAS Data Sets: Additional Features (Self-Study).......................................8-34
8.4 Solutions to Exercises....................................................................................................8-37
Chapter 9 Producing Summary Reports.............................................................. 9-1
9.1 Introduction to Summary Reports....................................................................................9-3
9.2 Basic Summary Reports...................................................................................................9-6
9.3 The REPORT Procedure ................................................................................................9-25
9.4 The TABULATE Procedure (Self-Study) ......................................................................9-40
9.5 Solutions to Exercises....................................................................................................9-55
Chapter 10 Introduction to Graphics (Optional).................................................. 10-1
10.1 Producing Bar and Pie Charts ........................................................................................10-3
10.2 Enhancing Output ........................................................................................................10-16
10.3 Producing Plots ............................................................................................................10-24
10.4 Solutions to Exercises..................................................................................................10-35
Chapter 11 Additional Resources......................................................................... 11-1
11.1 Resources .......................................................................................................................11-3
Appendix A Index ..................................................................................................... A-1
- 1
- 2
前往页