SAS 9 Programming Enhancements Marje Fecht, Prowerk Consulting Ltd Mississauga, Ontario, Canada

Similar documents
Easing into Data Exploration, Reporting, and Analytics Using SAS Enterprise Guide

Useful Tips from my Favorite SAS Resources

SAS Online Training: Course contents: Agenda:

Are Your SAS Programs Running You? Marje Fecht, Prowerk Consulting, Cape Coral, FL Larry Stewart, SAS Institute Inc., Cary, NC

I KNOW HOW TO PROGRAM IN SAS HOW DO I NAVIGATE SAS ENTERPRISE GUIDE?

Getting Familiar with SAS Version 8.2 and 9.0 Enhancements Sunil K. Gupta, Gupta Programming, Simi Valley, CA

Let the CAT Out of the Bag: String Concatenation in SAS 9

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

Base and Advance SAS

Big Data Executive Program

The Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data

SAS Macro. SAS Training Courses. Amadeus Software Ltd

Top 10 SAS Functions in A brief summary of SAS Communities Survey - by Flora Fang Liu

SAS ENTERPRISE GUIDE USER INTERFACE

Taming a Spreadsheet Importation Monster

Paper ###-YYYY. SAS Enterprise Guide: A Revolutionary Tool! Jennifer First, Systems Seminar Consultants, Madison, WI

A Quick and Gentle Introduction to PROC SQL

SAS System Powers Web Measurement Solution at U S WEST

SAS Visual Analytics Environment Stood Up? Check! Data Automatically Loaded and Refreshed? Not Quite

Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA

A Side of Hash for You To Dig Into

Techdata Solution. SAS Analytics (Clinical/Finance/Banking)

Choosing the Right Procedure

Efficient Elimination of Duplicate Data Using the MODIFY Statement

BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS

A Visual Step-by-step Approach to Converting an RTF File to an Excel File

Unlock SAS Code Automation with the Power of Macros

Introduction. Getting Started with the Macro Facility CHAPTER 1

Using SAS 9.4M5 and the Varchar Data Type to Manage Text Strings Exceeding 32kb

How Managers and Executives Can Leverage SAS Enterprise Guide

SAS Training BASE SAS CONCEPTS BASE SAS:

Beyond IF THEN ELSE: Techniques for Conditional Execution of SAS Code Joshua M. Horstman, Nested Loop Consulting, Indianapolis, IN

Going Under the Hood: How Does the Macro Processor Really Work?

How to Incorporate Old SAS Data into a New DATA Step, or What is S-M-U?

AURA ACADEMY SAS TRAINING. Opposite Hanuman Temple, Srinivasa Nagar East, Ameerpet,Hyderabad Page 1

Fifteen Functions to Supercharge Your SAS Code

High-Performance Procedures in SAS 9.4: Comparing Performance of HP and Legacy Procedures

Unit 3 Fill Series, Functions, Sorting

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center

SAS CURRICULUM. BASE SAS Introduction

Are Your SAS Programs Running You?

Statistics, Data Analysis & Econometrics

ABSTRACT Have you been programming in SAS for a while and just aren t sure how Enterprise Guide can help you? It isn t just a pretty face!

Choosing the Right Procedure

Run your reports through that last loop to standardize the presentation attributes

MIS Reporting in the Credit Card Industry

Key Reasons for SAS Data Set Size Difference by SAS Grid Migration Prasoon Sangwan, Piyush Singh, Tanuj Gupta TATA Consultancy Services Ltd.

Now That You Have Your Data in Hadoop, How Are You Staging Your Analytical Base Tables?

SAS Programming Techniques for Manipulating Metadata on the Database Level Chris Speck, PAREXEL International, Durham, NC

PharmaSUG Paper PO12

ABSTRACT INTRODUCTION TRICK 1: CHOOSE THE BEST METHOD TO CREATE MACRO VARIABLES

CMISS the SAS Function You May Have Been MISSING Mira Shapiro, Analytic Designers LLC, Bethesda, MD

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma

Contents of SAS Programming Techniques

Automating Preliminary Data Cleaning in SAS

Extending the Scope of Custom Transformations

A Practical Introduction to SAS Data Integration Studio

Using SAS Enterprise Guide to Coax Your Excel Data In To SAS

Step through Your DATA Step: Introducing the DATA Step Debugger in SAS Enterprise Guide

SAS Macro Language: Reference

PharmaSUG China Mina Chen, Roche (China) Holding Ltd.

SAS Business Rules Manager 1.2

All About SAS Dates. Marje Fecht Senior Partner, Prowerk Consulting. Copyright 2017 Prowerk Consulting

ET01. LIBNAME libref <engine-name> <physical-file-name> <libname-options>; <SAS Code> LIBNAME libref CLEAR;

SURVIVING THE SAS MACRO JUNGLE BY USING YOUR OWN PROGRAMMING TOOLKIT

PharmaSUG Paper PO10

Getting the Right DATES

Paper SAS Taming the Rule. Charlotte Crain, Chris Upton, SAS Institute Inc.

Copy That! Using SAS to Create Directories and Duplicate Files

Using Dynamic Data Exchange

Improving Your Relationship with SAS Enterprise Guide Jennifer Bjurstrom, SAS Institute Inc.

ABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30

Version 8 Base SAS Performance: How Does It Stack-Up? Robert Ray, SAS Institute Inc, Cary, NC

STATION

2997 Yarmouth Greenway Drive, Madison, WI Phone: (608) Web:

Guide Users along Information Pathways and Surf through the Data

Parallelizing Windows Operating System Services Job Flows

SAS Application to Automate a Comprehensive Review of DEFINE and All of its Components

Data Quality Control: Using High Performance Binning to Prevent Information Loss

Checking for Duplicates Wendi L. Wright

Foundations and Fundamentals. SAS System Options: The True Heroes of Macro Debugging Kevin Russell and Russ Tyndall, SAS Institute Inc.

Not Just Merge - Complex Derivation Made Easy by Hash Object

9 Ways to Join Two Datasets David Franklin, Independent Consultant, New Hampshire, USA

Binary, Hexadecimal and Octal number system

KEYWORDS Metadata, macro language, CALL EXECUTE, %NRSTR, %TSLIT

Text. Text Actions. String Contains

The Basics of PROC FCMP. Dachao Liu Northwestern Universtiy Chicago

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA

Can you decipher the code? If you can, maybe you can break it. Jay Iyengar, Data Systems Consultants LLC, Oak Brook, IL

Making Your SAS Data JMP Through Hoops Mira Shapiro, Analytic Designers LLC, Bethesda, MD

OASUS Spring 2014 Questions and Answers

What Do You Mean My CSV Doesn t Match My SAS Dataset?

Hash Objects Why Bother? Barb Crowther SAS Technical Training Specialist. Copyright 2008, SAS Institute Inc. All rights reserved.

CC13 An Automatic Process to Compare Files. Simon Lin, Merck & Co., Inc., Rahway, NJ Huei-Ling Chen, Merck & Co., Inc., Rahway, NJ

BreakOnWord: A Macro for Partitioning Long Text Strings at Natural Breaks Richard Addy, Rho, Chapel Hill, NC Charity Quick, Rho, Chapel Hill, NC

IF there is a Better Way than IF-THEN

Appendix A. The Preprocessor

The DATA Statement: Efficiency Techniques

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ

RWI not REI a Robust report writing tool for your toughest mountaineering challenges.

Transcription:

SAS 9 Programming Enhancements Marje Fecht, Prowerk Consulting Ltd Mississauga, Ontario, Canada ABSTRACT Performance improvements are the well-publicized enhancement to SAS 9, but what else has changed that impacts your SAS programs? This Hands On Workshop explores many new SAS 9 features including: new functions that may eliminate the need for complex expressions changes and additions to informats and formats interface additions and improvements new Export capabilities procedure enhancements and more... This workshop is beneficial for Version 8 SAS users who are getting started with SAS 9. INTRODUCTION The new architecture of SAS 9 enables performance improvements that are part of the big success story for the latest release of SAS software. The high-performance architecture enables multi-threaded processing for SAS procedures and multi-threaded access to external databases (eg: Oracle, Teradata, etc.). There are many in-depth presentations and papers at the conference focusing on SAS 9 enhancements including o SAS Add-In for Microsoft Office enabling you to exploit the power of SAS analytics directly from Microsoft WORD and Microsoft EXCEL o SAS Scalable Architecture for faster performance and improved usage of hardware resources o Web-based user interfaces o SAS Enterprise Guide 3.0, a powerful and flexible environment and toolset for end-to-end reporting. However, if your daily routine focuses on using BASE SAS to manipulate information and produce reporting, your primary interest may be the additions to SAS 9 that will streamline your programming, and reduce lengthy coding and logic. This hands-on-workshop focuses on the software enhancements that can change your daily coding routine. This Proceedings paper provides a brief synopsis of the topics that will be covered in the hands-on-workshop. The detailed hands-on-workshop presentation is available at the presentation, or from the author following the conference. INTERFACE ENHANCEMENTS When you first access SAS 9, you will notice few changes to the windowing environment. This means that you can instead focus your energies on performance and programmatic enhancements. A few interface enhancements include: additional selections in the Explorer window more integrated help facility Import / Export wizard support of o The latest versions of Microsoft Excel spreadsheets o Identification of a specific sheet to import from or export to o Ability to export to multiple sheets. 1

FORMATS AND INFORMATS You can improve the readability of your programs by using longer format and informat names. Character format and informat names can be a maximum of 31 characters. The maximum length for numeric format and informat names is now 32. COMPATIBILITY WITH PREVIOUS SOFTWARE VERSIONS If you require access to your Version 9 SAS data sets from Version 8, you should avoid using the longer format and informat names. In many situations, Version 8 can read Version 9 SAS data sets that use 8 byte or shorter format and informat names. For details on compatibility of SAS files across versions, see the Migration section of this paper. FUNCTIONS Prior to SAS 9, you probably used complex sequences of functions or steps to accomplish standard tasks. When you concatenated 2 character strings, you likely had to left justify, trim, and include an extra blank to get the proper result. If you needed to determine the second highest value in a list of variables for each observation, you likely used quite a few comparative statements or maybe even used a PROC. More than 60 analytic and data manipulation functions were added to SAS 9. Many functions were added to reduce code complexity. Additionally, the logic behind some functions was revised to improve performance (LENGTH and TRIM functions). REDUCE CODE COMPLEXITY Several character functions were added to reduce the complexity of common tasks. For example, the CATX function provides a straightforward solution to joining 2 strings so the result removes leading and trailing blanks and includes a designated character as a separator. Version 8 Solution: Combine = trim(left(char1)) left(char2); Version 9 Solution: Combine = CATX(, Char1, Char2); If you used repetitive INDEX and SUBSTR functions to determine how many times a word occurs in a character string, that task can be accomplished more easily in Version 9. The COUNT function determines the number of times argument 2 occurs in argument 1. SUBSTR has always been an effective function for extracting (or replacing) a portion of a character string. Two variations of SUBSTR are available in SAS 9: CHAR - to extract a single character from a text string JustOne = CHAR(String, 5); FIRST to grab just the first character from a text string Initial = FIRST(name); If you need to strip both leading and trailing blanks from a string, you can skip using the LEFT and TRIM functions and just use the new STRIP function. 2

COMPUTING STATISTICS OR QUANTITIES If you work frequently with Medians or Percentiles, you can now obtain those quantities in the DATA step. The MEDIAN function determines the median of non-missing values. The PCTL function accepts a percentage for argument 1 to specify the percentile of interest. It then computes that percentile for the list of values. If you need to find the second largest value in a list of values, or perhaps the third smallest value, the LARGEST and SMALLEST functions are available. In addition to supplying a list of values, you supply which placement you are looking for. ThirdLargest = LARGEST(3, a, b, c, d, e, f); CREATING MACRO VARIABLES Users of CALL SYMPUT commonly include LEFT, TRIM and PUT functions to make sure that the macro variable value is constructed properly. call symput( Max, trim(left(put(maxvalue, 8.))) ); The SAS 9 CALL SYMPUTX handles left justification, trimming, and also character conversion. call symputx( Max, maxvalue); DATA STEP ENHANCEMENTS Several DATA step enhancements may reduce your coding and enhance your results. LOG MESSAGING If you use the log for custom debugging or messaging, you may find the Version 9 PUTLOG statement useful. PUTLOG always writes to the LOG regardless of the current FILE destination. Additionally, if the message begins with ERROR:, WARNING:, or NOTE then the message will be appropriately colored in the LOG. USING AN IN OPERATOR The introduction of the IN operator many versions ago reduced the need for extensive IF statement comparisons. Now, the flexibility of the IN operator has been further enhanced to reduce manual input. Integer ranges can be specified with an IN operator: if code in (3 7:11 15 19:25) then put Found ; ANOTHER ADDITION WORTH EXPLORING Beyond the scope of this paper, two additional enhancements well worth exploring include: PERL regular expressions for fast search, extract, and replace Hash tables for searching a collection of values on a key and for sorting values in the DATA step. See support.sas.com for excellent explanations and examples. MACRO ENHANCEMENTS If you have become accustomed to the IN operator, you may have noticed its absence from the macro language. SAS 9 has implemented the IN mnemonic operator, similar in functionality to the DATA step IN operator. The macro implementation of the IN operator does not use parentheses for the right hand operand. To specify the delimiter for the macro IN operator, use the MINDELIMITER system option. Three new Macro functions assist you to assess the existence and scope of macro variables: o %SYMEXIST determines the existence of a macro variable o %SYMGLOBL indicates whether a macro variable is global o %SYMLOCAL indicates whether a macro variable is local. 3

PROCEDURE ENHANCEMENTS The Version 9 enhancements to BASE SAS procedures focus primarily on ODS formatting and on Multi-thread support. ENHANCED ODS FEATURES The following BASE procedures were enhanced with additional features usable with ODS: CONTENTS DATASETS CORR FREQ UNIVARIATE. MULTI-THREADED PROCESSING The following BASE procedures were enhanced to support multi-threaded processing. Using the NOTHREADS Procedure option can deactivate this feature. SORT SUMMARY / MEANS SQL TABULATE REPORT. MIGRATION / COMPATIBILITY OF SAS FILES To determine the compatibility of your SAS files between Version 8 and Version 9 (on the same platform), SAS has tools and assistance on the web. As of the date this paper was written, the following are some of the tools available through http://support.sas.com/rnd/migration/index.html Compatibility calculator Validation tools Data representation / encoding determination PROC MIGRATE details. If you do have to migrate your files from Version 8 to make them usable by Version 9, PROC MIGRATE is quite simple to use. The MIGRATE procedure supports most SAS file types (exceptions are well documented). CONCLUSION In addition to the long list of enhancements for SAS 9, there are many opportunities to improve your coding techniques using the new functions and statements added to BASE software. Removing complex coding and replacing with the more logical new functions can streamline coding. Usage of longer format and informat names improves program readability. The list of enhancements is extremely long; this paper s focus on day-to-day programming tasks is just a start towards effective use of Version 9. REFERENCES The SAS website support.sas.com has extensive and excellent documentation on the new features available with SAS 9. In addition to understandable overviews of the new architecture and resulting performance enhancements, you will also find product-by-product details of all new features. The SAS website (including the SAS Online Doc) served as the reference material for this paper. 4

CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Marje Fecht Prowerk Consulting Email: marje.fecht@prowerk.com Web: www.prowerk.com USA: PO Box 100549 Cape Coral, FL 33910 CANADA: PO Box 190 Port Credit Station Mississauga, ON L5G 4L7 Canada 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. 5