Learn to write SAS programs quickly and efficiently. Programming in SAS is flexible, but it can also be overwhelming. Many novice and experienced programmers learn how to write programs that use the DATA step and macros, but they often don’t realize that a simpler or better way can achieve the same results. In a user-friendly tutorial style, Practical and Efficient SAS® Programming: The Insider's Guide provides general SAS programming tips that use the tools available in Base SAS, including the DATA step, the SAS macro facility, and SQL. Drawing from the author’s 30 years of SAS programming experience, this book offers self-contained sections that describe each tip or trick and present numerous examples. It therefore serves as both an easy reference for a specific question, and a useful cover-to-cover read. As a bonus, the utility programs included in the appendixes will help you simplify your programs, as well as help you develop a sleek and efficient coding style. With this book, you will learn how to do the following: use the DATA step, the SAS macro facility, SQL, and other Base SAS tools more efficiently choose the best tool for a task use lookup tables simulate recursion with macros read metadata with the DATA step create your own programming style in order to write programs that are easily maintained Using this book, SAS programmers of all levels will discover new techniques to help them write programs quickly and efficiently. Contents About This Book What Does This Book Cover? Is This Book for You? What Should You Know about the Examples? Software Used to Develop the Book's Content Example Code and Data We Want to Hear from You About The Author Acknowledgments Chapter 1: My Favorite Functions Introduction Concatenating Strings Converting Numbers to Characters Adding Delimiters Using the OF Shortcut Removing Leading and Trailing Spaces Finding Non-Blank Values Creating Datetime Values Creating Macro Variables Finding Words Counting Words Replacing Substrings Using %SYSFUNC() to Run DATA Step Functions Chapter 2: Data Tables Introduction Copying Variable Attributes Reading Data with a SET Statement Concatenating Tables Interleaving Tables Using Multiple SET Statements Determining Which Table a Record Is From Using PROC SQL Choosing to Use PROC SQL Joining Using a Subquery Using a Correlated Subquery Using Lookup Tables Using a Format Using a Join Using a SET Statement With KEY= Using Hash Tables Updating Data In Place Using PROC SQL Using the MODIFY Statement Using PROC APPEND Finding Records Determining Whether a Table Exists Getting the Number of Records Verifying That a Table Has Records Re-creating Indexes Chapter 3: The Operating System Introduction Checking the Operating System Running Operating System Commands Using the X Statement Using the SYSTEM() Function Using a FILENAME Pipe Working with the File System Creating and Deleting Directories Working with Files Reading and Writing External Files Using the $VARYING. Format and Informat Using the FILEVAR= Option Reading Date and Time Values Creating a CSV File from a Data Table Reading a CSV File with Embedded Line Feeds Chapter 4: The Macro Facility Introduction Understanding Macro Variables Using the “Dot” in Macro Variable Names Determining How Many &s to Use Understanding Quotation Marks Using Macro Quoting Unquoting Forcing Single Quotation Marks Writing Macros Using Autocall Macros Determining When to Write a Macro Wrapping Long Lines of Code Using the IN Operator Testing for Blanks Validating Parameters Creating Macro Functions Chapter 5: SAS Programming Introduction Using the ABORT Statement Updating Option Values Getting Information from SASHELP Views Creating a Unique Key with PROC SQL Setting a Boolean Accumulating Values Replacing a Substring Using Data Values Tables to Create and Run Code Using Macro Variable Arrays Creating and Including Code Using CALL EXECUTE Taking Control of DATA Step Processing Branching Returning Deleting Subsetting Stopping Aborting Continuing Leaving Figuring Out Where You Are Counting Iterations Finding the End Finding Group Beginnings and Endings Chapter 6: Application Development Introduction Using Comments Choosing a Style Commenting Out Chunks of Code Dealing with Notes, Warnings, and Errors Getting Rid of Common Notes, Warnings, and Errors Creating Custom Error and Warning Messages Capturing Error and Warning Messages Protecting Your Password Encoding a Password Storing a Password Hiding a Password Using the PUT, PUTLOG, and %PUT statements Debugging with PUTLOG Using the VAR= Syntax Using Shortcuts Getting Rid of Unneeded Spaces Displaying a Macro Value in the SAS Log Using Macro Shortcuts Chapter 7: Advanced Tasks Introduction Sending Email A Single Message Multiple Messages Running Code in Parallel Using MPCONNECT Striping Data Simulating Recursion Reading Metadata Using the XML LIBNAME Engine Appendix A: Utility Macros Introduction Deleting Tables Getting the Number of Records Getting a Library’s Engine Name Getting a Variable Keep List Making ATTRIB Statements Making a Basic Format Making a Directory Path Creating Macro Variables from SYSPARM Setting Log Options Displaying Macro Notes for Debugging Refreshing Autocall Macros Appendix B: Display Manager Introduction Using the Enhanced Editor Indenting Your Code Commenting Out a Section of Code Converting a String to Uppercase or Lowercase Removing Excessive White Space Opening a New Enhanced Editor Window Using the Program Editor Customizing Function Keys Setting Options Using Line Commands Working with the Recall Stack Handling Unbalanced Quotation Marks Appendix C: Coding Style Introduction Indenting Aligning Handling Line Lengths Using Capital Letters (or Not) Naming Coding with Style References Index Learn to write SAS programs quickly and efficiently. Programming in SAS is flexible, but it can also be overwhelming. Many novice and experienced programmers learn how to write programs that use the DATA step and macros, but they often donâ€TMt realize that a simpler or better way can achieve the same results. In a user-friendly tutorial style, Practical and Efficient SAS® Programming: The Insider's Guide provides general SAS programming tips that use the tools available in Base SAS, including the DATA step, the SAS macro facility, and SQL. Drawing from the authorâ€TMs 30 years of SAS programming experience, this book offers self-contained sections that describe each tip or trick and present numerous examples. It therefore serves as both an easy reference for a specific question, and a useful cover-to-cover read. As a bonus, the utility programs included in the appendixes will help you simplify your programs, as well as help you develop a sleek and efficient coding style. With this book, you will learn how to do the following: use the DATA step, the SAS macro facility, SQL, and other Base SAS tools more efficiently choose the best tool for a task use lookup tables simulate recursion with macros read metadata with the DATA step create your own programming style in order to write programs that are easily maintained Using this book, SAS programmers of all levels will discover new techniques to help them write programs quickly and efficiently. "Learn to write SAS programs quickly and efficently. Programming in SAS is flexible, but it can also be overwhelming. Many novice and experienced programmers learn how to write programs that use the DATA step and macros, but they often don't realize that a simpler or better way can achieve the same results. In a user-friendly tutorial style, Practical and Efficent SAS Programming: The Insider's Guide provides general SAS programing tips that use the tools available in Base SAS, including the DATA step, the SAS macro facility, and SQL."-- Page 4 of cover « In a user-friendly tutorial style with numerous examples throughout, this book provides general SAS programming tips that use the tools available in Base SAS, including the DATA step, the SAS macro facility, and SQL. »-- Quatrième de couverture In a user-friendly tutorial style with numerous examples throughout, this book provides general SAS programming tips that use the tools available in Base SAS, including the DATA step, the SAS macro facility, and SQL. -- Edited summary from book