David S. Septoff Fidia Pharmaceutical Corporation

Similar documents
SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD

capabilities and their overheads are therefore different.

The 'SKIP' Statement

CHAPTER 7 Using Other SAS Software Products

The DATA Statement: Efficiency Techniques

HOW TO DEVELOP A SAS/AF APPLICATION

One SAS To Rule Them All

Matt Downs and Heidi Christ-Schmidt Statistics Collaborative, Inc., Washington, D.C.

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

Prevent Pane - Moving from MENU & PROGRAM Entries to FRAME Entries Loretta Golby, ISM Alberta Serge Dupuis, BKD Software Consultants Edmonton, Alberta

SAS Macro Programming for Beginners

Building Sequential Programs for a Routine Task with Five SAS Techniques

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA

Arthur L. Carpenter California Occidental Consultants, Oceanside, California

Your Own SAS Macros Are as Powerful as You Are Ingenious

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

Menu-Driven Interfaces Using SAS/FSP* Software and the SAS* Macro Language

Using SAS/SHARE More Efficiently

Batch vs. Interactive: Why You Need Both Janet E. Stuelpner. ASG. Inc Cary. North Carolina

SAS-USAGE UNDER ROSCOE/ETSO M.H.H. Lange, Centraal Beheer

SD10 A SAS MACRO FOR PERFORMING BACKWARD SELECTION IN PROC SURVEYREG

;... _... name; tsoge. scr purpose: Startup a TSO SAS session. notes: Assumes the TSO session has been logged on manually.

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

ABSTRACT DATA CLARIFCIATION FORM TRACKING ORACLE TABLE INTRODUCTION REVIEW QUALITY CHECKS

Data Warehousing. New Features in SAS/Warehouse Administrator Ken Wright, SAS Institute Inc., Cary, NC. Paper

-- ~ J ...

A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys

Introduction. Getting Started with the Macro Facility CHAPTER 1

A Table Driven ODS Macro Diane E. Brown, exponential Systems, Indianapolis, IN

Get Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp.

Using PROC FCMP to the Fullest: Getting Started and Doing More

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

MYOB Exo PC Clock. User Guide

While You Were Sleeping, SAS Was Hard At Work Andrea Wainwright-Zimmerman, Capital One Financial, Inc., Richmond, VA

Using PROC FCMP to the Fullest: Getting Started and Doing More

For example, let's say that we have the following functional specification:

SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD

INTRODUCTION TO THE SAS ANNOTATE FACILITY

Introduction to MDDBs

Sandra Hendren Health Data Institute

The Output Bundle: A Solution for a Fully Documented Program Run

Windows Script Host Fundamentals

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

Copy That! Using SAS to Create Directories and Duplicate Files

Macro Internals for the User Developer s Overview. Susan O Connor, SAS Institute Inc., Cary, NC

Macro Basics. Introduction. Defining and Using Macro Variables. Defining and Using Macros. Macro Parameters. Part 1. Chapter 1. Chapter 2.

My SAS Grid Scheduler

Using SAS/SCL to Create Flexible Programs... A Super-Sized Macro Ellen Michaliszyn, College of American Pathologists, Northfield, IL

A Generalized Macro-Based Data Reporting System to Produce Both HTML and Text Files

Gary L. Katsanis, Blue Cross and Blue Shield of the Rochester Area, Rochester, NY

FSEDIT Procedure Windows

Year 2000 Issues for SAS Users Mike Kalt, SAS Institute Inc., Cary, NC Rick Langston, SAS Institute Inc., Cary, NC

V6 Programming Fundamentals: Part 1 Stored Procedures and Beyond David Adams & Dan Beckett. All rights reserved.

SELF-MODIFYING SAS PROGRAMS: A DATA STEP INTERFACE

SAS Data Integration Studio Take Control with Conditional & Looping Transformations

Quick Results with the Output Delivery System

SAS Application Development Using Windows RAD Software for Front End

CA-MetaCOBOL + Online Programming Language Guide. Release 1.1 R203M+11DRP

Submitting SAS Code On The Side

Lecture 1 Getting Started with SAS

PharmaSUG Paper TT11

SAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board

SAS PROGRAM EFFICIENCY FOR BEGINNERS. Bruce Gilsen, Federal Reserve Board

Bruce Gilsen, Federal Reserve Board

Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility

The %let is a Macro command, which sets a macro variable to the value specified.

SAS System Powers Web Measurement Solution at U S WEST

The Ins and Outs of %IF

An Introduction to Macros Deb Cassidy

Storing and Reusing Macros

Base and Advance SAS

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

ABSTRACT INTRODUCTION RELEASE 6.06 ENVIRONMENT. I/O Engine Supervisor and the SAS Data Model. DATA Step Processor

Characteristics of a "Successful" Application.

A TALE OF TWO RELEASES: BENCHMARKING THE PERFORMANCE OF THE SAS SYSTEM RELEASE 6.06 AGAINST RELEASE 5.18

Developing Data-Driven SAS Programs Using Proc Contents

LESSON 13: LANGUAGE TRANSLATION

Merge Processing and Alternate Table Lookup Techniques Prepared by

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

title1 "Visits at &string1"; proc print data=hospitalvisits; where sitecode="&string1";

Use SAS/AF, SCL and MACRO to Build User-friendly Applications on UNIX

Other features of parametric programming

The two key ingredients mentioned earler are present here: The following program accomplishes all the necessary tasks: Binary Search: Method A

USING THE SAS SYSTEM FOR AN ANALYSIS AND REPORTING SYSTEM FOR EFFLUENT MONITORING

This chapter is intended to take you through the basic steps of using the Visual Basic

Business Processes for Managing Engineering Documents & Related Data

WHAT ARE SASHELP VIEWS?

The Ugliest Data I ve Ever Met

Unlock SAS Code Automation with the Power of Macros

Interactive Systems. NESUG '96 Proceedings ROUND PEGS INTO SQUARE HOLES: DATA WAREHOUSES FOR THE HARDWARE IMPAIRED

SAS Macro. SAS Training Courses. Amadeus Software Ltd

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

Web Content Management

SAS ENTERPRISE GUIDE USER INTERFACE

What Is SAS? CHAPTER 1 Essential Concepts of Base SAS Software

Effective Forecast Visualization With SAS/GRAPH Samuel T. Croker, Lexington, SC

Quicker Than Merge? Kirby Cossey, Texas State Auditor s Office, Austin, Texas

APPENDIX 2 Customizing SAS/ASSIST Software

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

Transcription:

UNLIMITING A LIMITED MACRO ENVIRONMENT David S. Septoff Fidia Pharmaceutical Corporation ABSTRACT The full Macro facility provides SAS users with an extremely powerful programming tool. It allows for conditional execution of DATA and of PROC steps, creation of parameter drive applications, passing SAS variables across steps and much much more. Unfortunately, the full power of Macro is not available in some operating environments. These programmers need not despair. SAS code can be written to simulate SAS Macros using the Base product available on all operating systems. This paper presents an example of a "SAS Macro Based System" developed in a VAX environment and, finally draws some conclusions on how SAS, as a programming language, can be just as powerful in a "partial" Macro environment as it is in a "full" Macro environment. INTRODUCTION The SAS system has experienced phenomenal growth in power, usage, and availability since its introduction. Originally designed to provide scientists and engineers with a data analysis tool that was powerful yet easier to use than traditional programming languages, the SAS DATA step give users the data manipulation capability of a high level language, while many SAS procedures provide a wide variety of easy to use data handling analysis, and reporting capabilities. Unfortunately, the full power of SAS is not available in all operating environments. Those that use the DEC (Digital Equipment Corporation) version of SAS, and all related environments, do not have the full power of the SAS Macro facility (SAS Institute, at SUGI 13, announced that full Macro will be available with the release of version 6 for the mini computer). These SAS users should not despair. From this paper you will get, if nothing else, a generic approach using the Base SAS product with its Macro capabilities to 'simulate' the capabilities of macro in the full Macro environments. This paper is designed to show how, in a partial macro environment, a SAS user can have power similar to a full macro environment. To explore this area, SAS processing as a whole must be placed in its proper context. The flow of the archetypical SAS job is shown below: 125

FIGURE 1 DATA u PROCEDURE u DATA, PROCEDURE u PROCEDURE 126

Notice that each DATA and PROC step is compiled and executed separately and in sequence. The next figure shows the structure of a typical modular system, in which amain routine controls system execution and calls the appropriate subroutines: FIGURE 2 MAIN ROUTINE SUBROUTINE SUBROUTINE SUBROUTINE SUBROUTINE SUBROUTINE 127

The figure below lists the three major requirements of software systems, and allows one to compare SAS without Macro to traditional programming languages as to the ability each has to satisfy the three requirements: System Requirements Modular Structure Conditional Execution Parameter Control Feature of Software Systems A main routine governs execution and calls subroutines when needed. Each subroutine performs a particular function Procedures are executed only when required Parameters governing an individual run of a system are passed to the system SAS Macro Component of Systems Macros which package code into main and subroutines. Macro %if logic Macro Variables One may look at the chart above and one may be confused as to how, in a partial macro environment, could a system be developed using the same set of requirements. Well the figure below may begin to answer this question: System ReQuirements Modular Structure Conditional Execution Parameter Control Solution In A Non Mainframe Environment Files which package code into Main routines and to functional pieces of the system 'OAT A NULL ' and 'PUT 'FILE', and - - ' '%INCLUDE' statements Parameter files and Macro Variables The requirement of modular structure, where a main routing controls the execution of the system and calls in subroutines, is different from standard SAS structure. It is this modular aspect of systems which is the most difficult for SAS to emulate; unfortunately, the other features of software systems are somewhat derived from this feature For example, 128

defining system execution parameters is a natural function of modular structure. In SAS without Macro there is no easy way for a system to read parameter values where they are needed. Conditional execution of blocks of code is likewise a natural function of the modular structure. It is certainly not a natural function of SAS, in which each SAS step is separate and sequentially executed. Macro, in a full macro environment allows a SAS-based system to have a modular structure in which a main Macro can control execution of the SAS steps, calling in other Macros as needed. In a partial macro environment this does not have to change. Instead of a main macro the system is developed using a main routine which will call subroutines and subroutines which will call other subroutines and so on. While macros allow for the packaging of code into functional units, so too do the subroutines just spoken of. The only thing that differs is that the %MACRO/%MEND are not used within the partial macro environment. The routines, like macro, can contain anything from a DATA or PROC step to multiple OAT A and/or PROC steps, and can be invoked whenever needed. Macro variables still are the controlling parameters; they are generated by the system and can be set by the user. Conditional execution is still a natural feature in a system developed under this environment of Macro. The packaging of code and the flexibility allowed by Macro is still retained. Macro Based System Within The Partial Macro Environment: 1. Main Routines - The important constant of any software system is its main routine - the routine or code that functions as the 'supervisor' of the system. It is the logical core of the system. A main routine in this environment is a set of code that initiates and directs the execution of the subroutines within the system. Compare this to a main routine with an environment with full macro capabilities and you can replace the word "routine" with the word "MACRO." The figure below shows a main routine from a full macro environment: %MACRO ADD (OLDDAT =, NEWDAT=, TRANS=, BYVARS=, SORT=NO); %NOBS (DATA=&TRANS) %1F&NOBS NE'O% THEN %00;/*PERFORM UPDATE'*/ %1F&SORT = YES% THEN %00;/*PERFORM SORT*/ 129

%END; %SORT %END; %1f&NEWDAT=%THEN %LET NEWDAT =&OLDDAT; %UPDATE %ELSE %PUT 'NOTE:*** NO TRANSACTIONS- STEP SKIPPED'; %MEND; The figure below is a main routine within a partial Macro environment. Note there are a few ways to read the parameters: 1. From a file 2. From a SAS data set. 3. From a SAS/AF Screen. This figure assumes that there is raw data file with the parameters: FILENAME PARMI PARM.DAT'; FILENAME OUT 'RUNFILE.SAS'; Options DQUOTE; Data _Null_; lnfile parm; Input olddat newdat trans Byvars Sort $ 1-8 $ 9-16 $17-24 $25-64 $65-68 Call symput ('olddat',olddat); Call symput ('Newdat',Newdat); Call symput ('Trans',Trans); Call symput ('Byvars',Byvars)' Call symput ('Sort',Sort); Run; %INC NOBS; rutility Routine*/ 130

SEPTOFF I Unllmiting Macros Data Null ; File OUT; If &NOBS NE 0 then DO; rok to update*/ If &SORT= "Yes" then put '%Include SORT;'; If &Newdat = then Call symput ('Newdat', "&olddat"); - - Put '%Include UPDATE;'; END; Else Put 'Note: *** NO Transactions stop skipped'; RUN; %Include OUT; The code is packaged within one file, using parameters provided by the user to govern execution. Inside the main routine skeletal code consisting of DATA and PROC steps generated through the processing; code such as the 'Data_Null_' Steps and the 'PUr and 'File' statements control what files lines of code are generated into and what files will ultimately be called in for execution. This routine allows the end-user the ability to run systems by supplying the required parameters. Once provided with the parameters the routine will produce the exact run desired. The end-user need not be concerned with anything else. The developer has the flexibility afforded through the full macro environment because all the code inside the main routine is generic and conditional. The generic nature of the code means that the macro variables need only be specified within the parm file (or what ever medium chosen to enter the run parameters). 2. Subroutines- Looking at the figure above, we can see how a main routine may call other routines. This allows standard sets of code to be stored as subroutines and brought in whenever necessary. Storing code in this manner allows for execution of functional parts of a system and contributes to the modularity of the code. The figure below illustrates a subroutine: Data &Newdat; Update &Master &Trans; By &Byvars; RUN; 131

One can certainly see that there really is not much difference between this figure and a macro created in a full macro environment. This reflects the desire to keep code modular as well as functional. 3. Parameter Control - Parameters that control this system can, as stated earlier, be referenced in several different ways. Global parameters can be set and default parameters can be stated. The important point here is that there is no loss of power when programming in this type of environment rather than a main frame environment. CONCLUSION While SAS and the full Macro facility are excellent tools for large scale system development, the mini computer user sometimes feels slighted by the lack of functions it may have on its system. SAS Macro in the mini environment has been shown to have the capabilities of SAS Macro on the Mainframe. It can be truly modular in structure, and can permit conditional execution of code and parameter passing without much problem. At the same time, the finely controllable nature of these systems is such that end-users in batch and interactive modes can have great control over their runs without ever dealing with actual code. ACKNOWLEDGEMENTS The author wishes to thank Frank Dorsey for his help with editing and Dianna Delemos for her outstanding typing job. The author may be contacted at: Fidia Pharmaceutical Corporation 1775 K Street, N.W. Washington, D.C. 20006 USA (202) 466-7066 DEC is a registered trademark of the Digital Equipment Corporation, USA SAS and SAS/AF are registered trademarks of SAS Institute, Cary, N.C., USA 132