SAS 9.4 Language Reference: Concepts, Sixth Edition
Total Page:16
File Type:pdf, Size:1020Kb
SAS® 9.4 Language Reference: Concepts, Sixth Edition SAS® Documentation November 4, 2019 The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2016. SAS® 9.4 Language Reference: Concepts, Sixth Edition. Cary, NC: SAS Institute Inc. SAS® 9.4 Language Reference: Concepts, Sixth Edition Copyright © 2016, SAS Institute Inc., Cary, NC, USA ISBN 978-1-62960-821-1 (Paperback) ISBN 978-1-62960-822-8 (PDF) 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 November 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. 9.4-P9:lrcon Contents What's New in the 9.4 Base SAS Language Reference: Concepts . xi PART 1 SAS System Concepts 1 Chapter 1 / Essential Concepts of Base SAS Software . 3 What Is SAS? . 3 Overview of Base SAS Software . 4 Components of the SAS Language . 5 Ways to Run Your SAS Session . 8 Customizing Your SAS Session . 11 Conceptual Information about Base SAS Software . 12 Chapter 2 / SAS Processing . 13 Definition of SAS Processing . 13 Types of Input to a SAS Program . 14 The DATA Step . 16 The PROC Step . 17 SAS Processing Restrictions for Servers in a Locked-Down State . 18 Chapter 3 / Rules for Words and Names in the SAS Language . 21 Words in the SAS Language . 21 Names in the SAS Language . 24 Chapter 4 / SAS Variables . 37 Definition of SAS Variables . 38 SAS Variable Attributes . 38 Ways to Create Variables . 42 Variable Type Conversions . 51 Aligning Variable Values in SAS Output . 52 Reordering Variables in SAS Output . 53 Automatic Variables . 54 SAS Variable Lists . 55 The OF Operator with Functions and Variable Lists . 63 Dropping, Keeping, and Renaming Variables . 64 Encrypting Variable Values . 67 Numerical Accuracy in SAS Software . 72 Chapter 5 / Missing Values . 95 Definition of Missing Values . 95 Creating Special Missing Values . 96 Order of Missing Values . 97 When Variable Values Are Automatically Set to Missing by SAS . 98 When Missing Values Are Generated by SAS . 100 Working with Missing Values . 102 iv Contents Chapter 6 / Expressions . 105 Definitions for SAS Expressions . 106 Examples of SAS Expressions . 106 SAS Constants in Expressions . 107 SAS Variables in Expressions . 113 SAS Functions in Expressions . 114 SAS Operators in Expressions . 114 Chapter 7 / Dates, Times, and Intervals . 127 About SAS Date, Time, and Datetime Values . 127 About Date and Time Intervals . 143 Chapter 8 / Error Processing and Debugging . 155 Types of Errors in SAS . 155 Error Processing in SAS . 165 Debugging Logic Errors in the DATA Step . 174 Chapter 9 / SAS Output . 175 Definitions for SAS Output . 175 Routing and Customizing SAS Output . 177 Sample SAS Output . 182 The SAS Log . 184 Chapter 10 / By-Group Processing in SAS Programs . 195 Definition of BY-Group Processing . 195 References for BY-Group Processing . 195 Chapter 11 / WHERE-Expression Processing . 197 Definition of WHERE-Expression Processing . 197 Where to Use a WHERE Expression . 198 Syntax of WHERE Expression . 199 Combining Expressions By Using Logical Operators . 209 Improving Performance of WHERE Processing . 210 Processing a Segment of Data That Is Conditionally Selected . ..