About This Book

The Intent of this Book

The goal of this book is to broaden the usage of a number of SAS programming tools and techniques. This is a very eclectic collection of ideas and tips that have been advanced over the years by any number of users. Some are quite advanced; however, most require only an intermediate understanding of the general concepts surrounding the tip. For instance if the technique involves the use of a double SET statement, you should have a decent understanding of the DATA step and how it is compiled and executed. Many of the techniques are even simple and are essentially suggestions along the lines of “Did you know that you can . . . .?”

What this Book is NOT

As is the case with any book that deals with a very broad range of topics, no single topic can be covered with all possible detail. For example SAS Formats are discussed in this book in several places; however, if you want more information on SAS formats, a full book has been written on that subject alone (Bilenas, 2005), consequently the content of that book will not be repeated in this one.

Except for a few of the especially advanced topics (I get to decide which ones), for most topics, this book makes no attempt to explain the basics. There are several very good “getting started” books on various aspects of SAS, this book is NOT one of them. If you want the basic how-to for a procedure or technique consult one of these other books. Of course, the reality is that some of the readers of this book will have more, or less, experience than others. I have made some attempt at offering brief explanations on most topics. Hopefully the depth of this book will be enough to get you started in the right direction for any given topic, even if it does not cover that topic thoroughly.

By its very nature this book is not designed to be read linearly, front to back, instead I anticipate that the reader will use it either as a reference for a specific technique, an exploration tool for learning random new ‘tidbits’, or perhaps most effectively as a sleeping aid. The MORE INFORMATION and SEE ALSO sections, as well as, the topical index in Appendix A, and the usage index in Appendix B should help you find and navigate to related topics.

What this Book is . . .

There are literally hundreds of techniques used on a daily basis by the users of SAS software as they perform analyses and generate reports. Although sometimes obscure, most of these techniques are relatively easy to learn and generally do not require any specialized training before they can be implemented. Unfortunately a majority of these techniques are used by only a very small minority of the analysts and programmers. They are not used more frequently, simply because a majority of SAS users have not been exposed to them. Left to ourselves it is often very difficult to ‘discover’ the intricacies of these techniques and then to sift through them for the nuggets that have immediate value. Certainly this is true for myself as I almost daily continue to learn new techniques. I regret that the nugget that I learn tomorrow will not make it into this book.

This book introduces and demystifies a series of those nuggets. It covers a very broad range of mostly Base SAS topics that have proven to be useful to the intermediate or advanced SAS programmer who is involved with the analysis and reporting of data. The intended audience is expected to have a firm grounding in Base SAS. For most of the covered topics, the book will introduce useful techniques and options, but will not ‘teach the procedure’.

I have purposefully avoided detailed treatment of advanced topics that are covered in other books. These include, but are not limited to: statistical graphics (Friendly, 1991), advanced ODS topics (Haworth et al, 2009), the macro language (Carpenter, 2004), PROC REPORT (Carpenter, 2007a), PROC TABULATE (Haworth, 1999), SAS/GRAPH (Carpenter and Shipp, 1995), and the annotate facility (Carpenter, 1999).

The more advanced users may find that they are already using some of these techniques, and I hope that this is the case for you. However I believe that the range of topics is broad enough that there will be something for everyone. It may only take a single nugget to ‘pay for the book’.

Intended Audience

This book is intended to be used by intermediate and advanced SAS programmers and SAS users who are faced with large or complex reporting and analysis tasks. It is especially for those that have a desire to learn more about the sometimes obscure options and techniques used when writing code for the advanced analysis and reporting of data. SAS is complex enough that it can be very difficult, even for an advanced user, to have a knowledge base that is diverse enough to cover all the necessary topics. Covering, at least at a survey level, as many of these diverse topics as possible is the goal of this book.

This book has not been written for the user who is new to SAS. While this book contains a great deal that the new user will find valuable, unlike an introductory book that goes into great detail, most of the topics in this book are fairly brief and are intended more to spark the reader’s interest rather than to provide a complete reference. The assumption is that most readers of this book will have sufficient background to ‘dig deeper’ for the details of the topics that most interest them.

Overview of Chapters

Part 1 Data Preparation

Most tasks involving the use of SAS revolve around the data. The analyst is often responsible for bringing the data into the SAS world, manipulating it so that it can be analyzed, and for the analysis preparation itself. Although not all phases of data preparation are necessary for every project or task, the analyst must be prepared for a wide variety of variations on the theme.

Chapter 1: Moving, Copying, Importing and Exporting Data

The issues surrounding the movement of data into and out of the SAS environment are as diverse as the types and sources of data.

Chapter 2: Working with Your Data

Once the data is available to SAS there are a number of ways that it can be manipulated and prepped for analysis. In addition to the DATA step, SAS contains a number of tools to assist in the process of data preparation.

Chapter 3: Just in the DATA Step

There are a number of tools and techniques that apply only to the DATA step.

Chapter 4: Sorting the Data

The order of the rows in a data table can affect not only how the data are analyzed, but also how it is presented.

Chapter 5: Working with Data Sets

Very often there are things that we can do to the data tables that will assist with the analysis and reporting process.

Chapter 6: Table Lookup Techniques

The determination of a value for a variable based on another variable’s value requires a lookup for the desired value. As our tables become complex lookup techniques can become quite specialized.

Part 2 Data Summary, Analysis, and Reporting

The use of SAS for the summarization and analysis of data is at the heart of what SAS does best. And of course, since there is so much that you can do, it is very hard to know of all the techniques that are available. This part of the book covers some of the more useful techniques, as well as a few that are underutilized, either because they are relatively new, or because they are somewhat obscure.

Several of these techniques apply to a number of different procedures. And the discussion associated with them can be found in various locations within this book. In all cases these are techniques of which I believe the SAS power user should be aware.

Chapter 7: MEANS and SUMMARY Procedures

Although almost all SAS programs make use of these procedures, there are a number of options and techniques that are often overlooked.

Chapter 8: Other Reporting and Analysis Procedures

Several commonly used procedures have new and/or underutilized options, which when used, can greatly improve the programmer’s efficiency.

Chapter 9: SAS/GRAPH Elements You Should Know – Even If You Don’t Use SAS/GRAPH

A number of statements, options, and techniques that were developed for use with SAS/GRAPH can also be taken advantage of outside of SAS/GRAPH.

Chapter 10: Presentation Graphics – More than Just SAS/GRAPH

A number of Base SAS procedures as well as procedures from products other than SAS/GRAPH produce presentation-quality graphics. Some of the highlights and capabilities of those procedures are discussed in this chapter.

Chapter 11: Output Delivery System

Most reporting takes advantage of the Output Delivery System. A great deal has been written about ODS; in this chapter a few specialized techniques are discussed.

Part 3 Techniques, Tools, and Interfaces

In addition to the coding nuts and bolts of SAS, there are a number of tools and techniques, many of which transcend SAS that can be especially helpful to the developer. This part of the book is less about DATA and PROC steps and more about how they work together and how they interface with the operating environment.

Chapter 12: Taking Advantage of Formats

There is a great deal more that you can do with formats in addition to the control of the display of values.

Chapter 13: Interfacing with the Macro Language

When building advanced macro language applications there are a number of things of which the developer should be aware.

Chapter 14: Operating System Interface and Environmental Control

While not necessarily traditional SAS, application programmers must be able to interface with the operating system, and there is a great deal more than one would anticipate at first glance.

Chapter 15: Miscellaneous Topics

There are a number of isolated topics that, while they do not fit into the other chapters, do indeed still have value.

Software Used to Develop the Book’s Content

This book is based on SAS 9.3. Although every effort has been made to include the latest information available at the time of printing, new features will be made available in later releases. Be sure to check out the SAS Web site for current updates and check the SAS OnlineDoc for enhancements and changes in new releases of SAS.

Using this Book

Initial publication of this book will be the traditional hard copy paper. As time and technology permits, it is hoped that the book will also be made available in various forms electronically.

Display of SAS Code and Output

The type face for the bulk of the text is Times New Roman.

The majority of the code will appear in a shaded box and will appear in the Courier New font.

SAS Code appears in a shaded box.

Text written to the SAS LOG will appear in a box with a dotted border, and like the code box the text will be in the Courier New font.

LOG Window in a box with a dotted border.

The Output Delivery System, ODS, has been used to present the output generated by SAS procedures. Throughout the book it is common to show only portions of the output from a given procedure. Output written to the LISTING destination will appear in an un-shaded solid bordered box using the Courier New font. The output written to other ODS destinations will be presented as screen shot graphics appropriate to that destination. Although color is included in most ODS styles, color will not be presented in this book. If you want to see the color output, you are encouraged to execute the sample code associated with the appropriate section so that you can see the full output. Occasionally raw data will also be presented in an unshaded box with a solid border.

SAS OUTPUT Window in an unshaded box.

SAS terms, keywords, options and such are capitalized, as are data set and variable names. Terms that are to be emphasized are written in italics, as are nonstandard English words (such as fileref) that are common in the SAS vernacular.

References and Links

Throughout the book references are included so that the reader can find more detail on various topics. Most, but not all, of these references are shown in the MORE INFORMATION and SEE ALSO sections.

MORE INFORMATION Sections

Related topics that are discussed further within this book are pointed out in the MORE INFORMATION section that follows most sections of the book. Locations are identified by section number.

SEE ALSO Sections

References to sources outside of this book are made in the SEE ALSO section. Citations refer to a variety of sources. Usually the citation will include the author’s name and the year of publication. Additional detail for each citation, including a live link, can be found in the References section.

There are also a number of references to SAS Institute’s support site (support.sas.com). Unfortunately internal addressing on this site is changing constantly, and while every effort has been made to make all links as current as possible, any links to this site should be considered to be suspect until verified.

Locating References

If you are reading this book using an electronic device, you will notice that most of the links cited in the SEE ALSO sections are live. Each of the papers or books listed also has a live link in the References section of this book. Every attempt has been made to ensure that these links are current; however, it is the very nature of the Web that links change, and this will be especially true throughout the life of this book.

Whether you are reading this book using the traditional paper format or if you are using an electronic device all of the links in this book, including the links to all the cited papers in the References section, as well as the links embedded within the text of the book, have been made available to you as live links on sasCommunity.org under a category named using the title of this book. As I discover that links have gone stale or have changed they will be updated at this location whenever possible. Please let me know if you discover a stale or bad link.

Navigating the Book

In addition to the standard word index at the back of the book two appendixes have been provided that will help you navigate the book and to find related topics:

The MORE INFORMATION sections will also guide you to related topics elsewhere within the book.

Using the Sample Programs and Sample Data

A series of sample programs and data sets from this book are available for your use. These are available in a downloadable ZIP file, either from the author page for this book at support.sas.com/authors or from sasCommunity.org. The sample programs are organized by chapter, and named according to the section in which they are described. They can be used ‘out of the box’; however, you may need to establish some macro variables and libraries. This is done automatically for you if you use the suggested AUTOEXEC.SAS program and the assumed folder structure.

The ZIP file will contain the primary folder InnovativeTechniques and the three subfolders SASCode, Results, and Data. To use the SAS programs you will want to first set up a SAS environment as described in Chapter 14, “Operating System Interface and Environmental Control.” The SASCode directory contains an AUTOEXEC.SAS program that you will want to take advantage of by following the instructions in Section 14.2 and 14.1.1. As it is currently written the autoexec program expects that the SAS session initialization will include an &SYSPARM definition (see Section 14.1.1).

The following SAS catalogs and data tables are used by the sample programs, and are made available through the use of the ADVRPT libref, which is automatically established by the AUTOEXEC.SAS program.

The clinical trial study data has been fabricated for this book and does not reflect any real or actual study. Although the names of drugs and symptoms are nominally factual, data values do not necessarily reflect real-world situations. Careful inspection of the data tables will surface a number of data issues that are, in part, discussed throughout the book. Although I have introduced some data errors for use in this book, the bulk of the ADVRPT.DEMOG data set was created by Kirk Lafler, Software Intelligence Corporation, and has been used with his permission.

The manufacturing data is nominally actual data, but it has been highly edited for use in this book. I would suggest that you do not adjust any process controls based on this data.

Data Group Data Group Member Name Description

Clinical Trial

Study Data

AE

Adverse events

CLINICNAMES

Clinic names and locations

CONMED

Concomitant Medications

DEMOG

Demographic Information

LAB_CHEMISTRY

Laboratory Chemistry results

Study Metadata

DATAEXCEPTIONS

Data exclusion criteria

DSNCONTROL

Data set level metadata

FLDCHK

Automated data field check metadata (see Section 13.5.2)

Manufacturing

Manufacturing Data

MFGDATA

Manufacturing process test data

Miscellaneous

Function Definitions

FUNCTIONS

User-defined functions using PROC FCMP (see Section 15.2)

Password Control

PASSTAB

See Section 5.4.2

PWORD

This is a simplified version of the PASSTAB data set (See Section 2.1.2)

Catalog Name Member Type Description
FONTS Fonts, graphical User-defined SAS/GRAPH font
PROJFMT Formats User-defined format library
SASMACR Stored Compiled Macros Stored compiled macro library (see Section 13.9)

Corrections, Typos, and Errors

Although every effort has been made by numerous reviewers and editors to catch my typos and technical errors, it is conceivable – however unlikely – that one still remains in the book. Any errata that are discovered after publication will be collected and published on sasCommunity.org. Please visit the category dedicated to this book on sasCommunity.org. There you can get the latest updates and corrections, and you can let me know of anything that you discover. Will you be the first to report something?

Author Page

You can access the author page for this book at http://support.sas.com/authors. This page includes several features that relate to this specific book, including more information about the book and author, book reviews, and book updates; book extras such as example code and data; and contact information for the author and SAS Press.

Additional Resources

SAS offers a rich variety of resources to help build your SAS skills and explore and apply the full power of SAS software. Whether you are in a professional or academic setting, we have learning products that can help you maximize your investment in SAS.

Bookstore

http://support.sas.com/publishing/

Training

http://support.sas.com/training/

Certification

http://support.sas.com/certify/

Higher Education Resources

http://support.sas.com/learn/

SAS OnDemand for Academics

http://support.sas.com/ondemand/

Knowledge Base

http://support.sas.com/resources/

Support

http://support.sas.com/techsup/

Learning Center

http://support.sas.com/learn/

Community

http://support.sas.com/community/

SAS Forums

http://communities.sas.com/index.jspa

User community wiki

http://www.sascommunity.org/wiki/Main_Page

Comments or Questions?

If you have comments or questions about this book, you can contact the author through SAS as follows:

Mail:

SAS Institute Inc.
SAS Press
Attn: Art Carpenter
SAS Campus Drive
Cary, NC 27513

Email:

[email protected]

Fax:

(919) 677-4444

Please include the title of this book in your correspondence.

SAS Publishing News

Receive up-to-date information about all new SAS publications via e-mail by subscribing to the SAS Publishing News monthly eNewsletter. Visit support.sas.com/subscribe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset