ection>
The correct bibliographic citation for this manual is as follows: Blum, James and Jonathan Duggins. 2019. Fundamentals of Programming in SAS®: A Case Studies Approach. Cary, NC: SAS Institute Inc.
Fundamentals of Programming in SAS®: A Case Studies Approach
Copyright © 2019, SAS Institute Inc., Cary, NC, USA
978-1-64295-228-5 (Hardcover)
978-1-63526-672-6 (Paperback)
978-1-63526-671-9 (Web PDF)
978-1-63526-669-6 (epub)
978-1-63526-670-2 (mobi)
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.
The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher is illegal and punishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronic piracy of copyrighted materials. Your support of others’ rights is appreciated.
U.S. Government License Rights; Restricted Rights: The Software and its documentation is commercial computer software developed at private expense and is provided with RESTRICTED RIGHTS to the United States Government. Use, duplication, or disclosure of the Software by the United States Government is subject
to the license terms of this Agreement pursuant to, as applicable, FAR 12.212, DFAR 227.7202-1(a), DFAR 227.7202-3(a), and DFAR 227.7202-4, and, to the extent required under U.S. federal law, the minimum restricted rights as set out in FAR 52.227-19 (DEC 2007). If FAR 52.227-19 is applicable, this provision serves as notice under clause (c) thereof and no other notice is required to be affixed to the Software or documentation. The Government’s rights in Software and documentation shall be only those set forth in this Agreement.
SAS Institute Inc., SAS Campus Drive, Cary, NC 27513-2414
July 2019
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 software may be provided with certain third-party software, including but not limited to open-source software, which is licensed under its applicable third-party software license agreement. For license information about third-party software distributed with SAS software, refer to http://support.sas.com/thirdpartylicenses.
Foreword
To Readers
This book is designed to help you develop an understanding of the SAS programming language and to help you develop good programming practices. It is intended as a learning guide and a skill builder, not as a reference book. To that end, it introduces sets of topics within each chapter that are connected through a single case study. Concepts are introduced on an as-needed basis to complete required tasks, so you are immediately exposed to writing complete programs. As further concepts are introduced they might be new topics, or they might revisit previously introduced topics at a more complex level. This reflects how many of the best SAS programmers have built their talents—by continually adding layers of knowledge onto a base set of skills. The book mimics this type of experience by increasing the complexity of the case study, requiring the addition of newer skills, or more complex versions of earlier skills, as they are needed.
Because of this circling back to content from previous chapters, a pedagogical concept known as a spiral curriculum, you will not learn everything this book covers on a topic in any single chapter. Of course, no one book could serve the purpose of giving a complete treatment of all concepts included; therefore, you will often be referred to outside resources, such as SAS Documentation, for a full description of syntax or for more detailed commentary. SAS Documentation is the standardized name used in this text for the collection of help files and examples provided by SAS. This documentation is available via the Help menu in SAS or online. Reading such references is a strategy commonly used by the best SAS programmers to refine their abilities and is an important habit for you to develop to build your skills as a SAS programmer and to expand on those skills in the future.
Due to the introduction of concepts in spiral fashion, it is important to begin with the setup material in Chapter 1 and then to proceed through the book sequentially. For easy reference, the numbering on all output in Chapters 1 through 7 directly corresponds to the number of the program that generates it. However, not all programs generate output. In all chapters, the programs, output, tables, and figures are numbered sequentially within each section. The same case study is used to provide continuity through the narrative when building on earlier concepts. Other case studies are also available for use to build continuity for additional programming activities and exercises. This includes a case study located in Chapter 8 for which the sections are aligned with the learning objectives of each chapter. Additional case studies are available online by visiting the author page for either author.
To Classroom Instructors
As stated in the previous section, this book is designed to tap into some of the best practices in educational theory as it spirals back onto topics throughout your course. It is designed by instructors with over 25 years of combined experience in teaching SAS either in the classroom or in industry. The more technical details are isolated in their own sections so that you can easily include or exclude them to fit the needs of your course. Multiple case studies are also provided so that the case study assignments can be customized for your students’ interests and to the content presented in your course. The case study provided in Chapter 8 ensures students have immediate access to a case study for reference while reading the text. Additional case studies are made available through the author pages for either author to ensure you get the benefit of updated materials on a regular basis. Any instructional materials will also be available either via the author pages (for public resources) or by contacting SAS to verify your status as an instructor (for instructor-only materials). These resources will be regularly updated.
About the IPUMS CPS Data
The IPUMS CPS data includes the Integrated Public Use Microdata Series (IPUMS) and Current Population Survey (CPS) beginning in 1962. These data sets provide person- and household-level information about a variety of demographic variables. A cross-section of recent data (2001, 2005, 2010, and 2015) was released for this publication and is included here as the main case study in the narrative. Visit https://cps.ipums.org to learn more about the IPUMS CPS or to extract newer data to continue honing your SAS programming skills.
About This Book
What Does This Book Cover?
This text covers a wide set of topics available in the Base SAS software including:
DATA step programming including:Reading data sets from non-SAS sourcesCombining and restructuring SAS data setsFunctions and conditional logicDO loops and arrays
Basic analysis procedures: MEANS, FREQ, CORR, and UNIVARIATE
Reporting procedures: CONTENTS, PRINT, and REPORT
Restructuring data with PROC TRANSPOSE
Visualization with the SGPLOT and SGPANEL procedures
SAS formats and the FORMAT procedure
Output Delivery System
While this book covers