Practical and Efficient SAS Programming
205 pages
English

Vous pourrez modifier la taille du texte de cet ouvrage

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris

Practical and Efficient SAS Programming , livre ebook

-

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus
205 pages
English

Vous pourrez modifier la taille du texte de cet ouvrage

Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus

Description

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.

Sujets

Informations

Publié par
Date de parution 06 septembre 2017
Nombre de lectures 1
EAN13 9781635262223
Langue English
Poids de l'ouvrage 18 Mo

Informations légales : prix de location à la page 0,0080€. Cette information est donnée uniquement à titre indicatif conformément à la législation en vigueur.

Extrait

Practical and Efficient SAS Programming
The Insider s Guide
Martha Messineo
The correct bibliographic citation for this manual is as follows: Messineo, Martha. 2017. Practical and Efficient SAS Programming: The Insider s Guide . Cary, NC: SAS Institute Inc.
Practical and Efficient SAS Programming: The Insider s Guide
Copyright 2017, SAS Institute Inc., Cary, NC, USA
ISBN 978-1-63526-023-6 (Hard copy) ISBN 978-1-63526-222-3 (EPUB) ISBN 978-1-63526-223-0 (MOBI) ISBN 978-1-63526-224-7 (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
September 2017
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 .
Contents
About This Book
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
About This Book
What Does This Book Cover?
This book does not teach a novice how to program with SAS. Its purpose is to provide SAS programmers with better tools for accomplishing a variety of tasks using DATA steps, macros, the SQL procedure, and other procedures.
It covers data manipulation, tricks for writing better programs, utilities to simplify application development, and a variety of techniques, including using recursion, using lookup tables, and reading metadata.
Is This Book for You?
The expected audience for this book is SAS programmers with some-or a lot of-experience in writing SAS code. You should have some experience with the DATA step (basic concepts and the use of functions) and with the macro facility (macro variables and simple macro programming). In addition, a basic understanding of PROC SQL and other standard procedures is useful.
What Should You Know about the Examples?
This book includes examples that you can run for yourself to gain hands-on experience with SAS. All of the examples are self-contained. Most of the data that is used is from the standard sashelp sample tables (for example, sashelp.class and sashelp.cars). A few examples create their own data tables.
Software Used to Develop the Book's Content
Base SAS 9.4 was used to develop the content for this book. Some of the code works in any version of SAS, some only works in SAS 9, and some only works in SAS 9.4. In addition, there is one example that requires access to the SAS Metadata Repository, formerly known as the SAS Open Metadata Repository , so the SAS Metadata Server must be installed to use these examples.
The code was primarily developed on

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents