Transcription of Step-by-Step Programming with Base SAS 9.4, Second …
1 Step-by-Step Programming with base SAS , Second EditionSAS DocumentationJuly 27, 2020 The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2015. Step-by-Step Programming with base SAS , Second Edition. Cary, NC: SAS Institute Programming with base SAS , Second EditionCopyright 2015, SAS Institute Inc., Cary, NC, USAISBN 978-1-62959-894-9 (Paperback)ISBN 978-1-62960-806-8 (PDF)All Rights Reserved. Produced in the United States of 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 a web download or e-book.
2 Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this 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 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.
3 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 , DFAR (a), DFAR (a), and DFAR , and, to the extent required under federal law, the minimum restricted rights as set out in FAR (DEC 2007). If FAR 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 Institute Inc.
4 , SAS Campus Drive, Cary, NC 27513-2414 August 2020 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 brand and product names are trademarks of their respective :basessContentsAbout This Book .. xiiiWhat s New in Step-by-Step Programming with base SAS .. xixAccessibility .. 0 PART 1 Introduction to the SAS System1 Chapter 1/What is the SAS System? .. 3 Introduction to the SAS System.
5 3 Components of base SAS Software .. 4 Output Produced by the SAS System .. 8 Ways to Run SAS Programs .. 11 Running Programs in the SAS Windowing Environment .. 13 Summary .. 16 Learning More .. 16 Chapter 2/Working with Output Defaults .. 17 Working with Output Defaults .. 17 Learning More .. 21 PART 2 Getting Your Data into Shape23 Chapter 3/Introduction to DATA step Processing .. 25 Introduction to DATA step Processing .. 26 The SAS Data Set: Your Key to the SAS System .. 26 How the DATA step Works: A Basic Introduction.
6 32 Supplying Information to Create a SAS Data Set .. 40 Summary .. 47 Learning More .. 48 Chapter 4/Starting with Raw Data: The Basics .. 51 Introduction to Raw Data .. 52 Examine the Structure of the Raw Data: Factors to Consider .. 52 Reading Unaligned Data .. 53 Reading Data That Is Aligned in Columns .. 57 Reading Data That Requires Special Instructions .. 61 Reading Unaligned Data with More Flexibility .. 64 Mixing Styles of Input .. 66 Summary .. 69 Learning More .. 70 Chapter 5/Starting with Raw Data: Beyond the Basics.
7 71 Introduction to Beyond the Basics with Raw Data .. 72 Testing a Condition Before Creating an Observation .. 72 Creating Multiple Observations from a Single Record .. 74 Reading Multiple Records to Create a Single Observation .. 78 Problem Solving: When an Input Record Unexpectedly Does Not Have Enough Values .. 86 Summary .. 89 Learning More .. 91 Chapter 6/Starting with SAS Data Sets .. 93 Introduction to Starting with SAS Data Sets .. 93 Understanding the Basics .. 94 Input SAS Data Set for Examples.
8 94 Reading Selected Observations .. 97 Reading Selected Variables .. 98 Creating More Than One Data Set in a Single DATA step .. 101 Using the DROP= and KEEP= Data Set Options for Efficiency .. 103 Summary .. 105 Learning More .. 106 PART 3 Basic Programming107 Chapter 7/Understanding DATA step Processing .. 109 Overview of DATA step Processing .. 109 Input SAS Data Set for Examples .. 110 Adding Information to a SAS Data Set .. 111 Defining Enough Storage Space for Variables .. 116 Conditionally Deleting an Observation.
9 117 Summary .. 118 Learning More .. 118 Chapter 8/Working with Numeric Variables .. 121 Introduction to Working with Numeric Variables .. 121 About Numeric Variables in SAS .. 122 Input SAS Data Set for Examples .. 122 Calculating with Numeric Variables .. 124 Comparing Numeric Variables .. 128 Storing Numeric Variables Efficiently .. 130 Summary .. 132 Learning More .. 132 Chapter 9/Working with Character Variables .. 135 Introduction to Working with Character Variables .. 135 Input SAS Data Set for Examples.
10 136 Identifying Character Variables and Expressing Character Values .. 137 Setting the Length of Character Variables .. 139 Handling Missing Values .. 141 Creating New Character Values .. 144 Saving Storage Space by Treating Numbers as Characters .. 149 Summary .. 150 Learning More .. 151ivContentsChapter 10/Acting on Selected Observations .. 153 Introduction to Acting on Selected Observations .. 153 Input SAS Data Set for Examples .. 154 Selecting Observations .. 156 Constructing Conditions .. 160 Comparing Characters.