SAS Macro. SAS Training Courses. Amadeus Software Ltd

Size: px
Start display at page:

Download "SAS Macro. SAS Training Courses. Amadeus Software Ltd"

Transcription

1 SAS Macro SAS Training Courses By Amadeus Software Ltd

2 AMADEUS SOFTWARE LIMITED SAS TRAINING Amadeus have been delivering SAS Training since 1989 and our aim is to provide you with best quality SAS training where, when and how you choose. Delivery Options Available: Public Training On-Site Training On-Demand Training Types of Training Available: Training Courses: Classroom based with a mixture of demonstration sessions and workshop sessions. Each delegate receives a copy of course material which can be used as reference material after the class. Workshops: Classroom based with practical sessions. There will be very little in the way of lecturing; delegates will be expected to actively contribute during the workshop. Written material will be provided to delegates, this material will not be a textbook but a record of the practical steps followed during the workshop. On-Demand: Amadeus On-Demand training is delivered through a web browser to any computer or device with internet access. Training is recorded and conducted by our most experienced instructors using in-depth examples, video demonstrations and animations. RECOMMENDED TRAINING CURRICULUM PATH CONTACT Amadeus Software Limited Mulberry House, 9 Church Green, Witney, Oxon, OX28 4AZ, England. Tel: +44 (0) info@amadeus.co.uk Web Site:

3 Credits Credits This SAS Software training course was written by Staff of Amadeus Software Ltd. Version 6.3 Copyright Notice Copyright 2013 by Amadeus Software Ltd. All rights reserved. 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 prior permission of the publisher, Amadeus Software Ltd, Witney, Oxfordshire, England. Trademark Notice The Amadeus logo is a trademark of Amadeus Software Ltd, Witney, Oxfordshire, England. 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 All other trademarks recognised. Disclaimer These course notes are intended to supplement documentation supplied by SAS Institute, and not to replace it. Where SAS syntax is given here, it may not include all possible options. Similarly, lists of statements, functions, formats, macro variables and other SAS features given here are not intended to be comprehensive. For complete and up-to-date information, please refer to the SAS Institute documentation..

4 Table of Contents Table of Contents M1 INTRODUCTION... Common Coding Tasks... Example 1... Example 2... Example 3... Example 4 (Optional - SAS/Graph users)... General Strategy... Workshop Session... M2 MACRO VARIABLES Automatic Macro Variables... Automatic System Macro Variables... Operating System Dependency... Determining the Values of Macro Variables... Using SASHELP.VMACRO... Using %PUT Statement... Creating User-Defined Macro Variables... %LET Statement... Macro Functions... Optional - SAS/Connect Software Users... Resolution Considerations... Limiting the Extent of Resolution... Multi - Pass Resolution... Rules for Dealing with Multiple Ampersands... Debugging Option - SYMBOLGEN... Macro Variables vs. DATA Step Variables... Workshop Session... M3 MACROS... Definition of a Macro... Macro Definition... Debugging Option MCOMPILENOTE... The Macro Call... Debugging Option MPRINT... Passing Parameters... Positional Parameters... Keyword Parameters... Combination of Positional and Keyword Parameters... Varying Number of Parameters... 1

5 Table of Contents Compilation and Execution Phases... Deleting a Compiled Macro... Other Macro Forms (Optional)... Workshop Session... M4 BEHIND THE SCENES... Symbol Tables Rules... Example 1... Example 2... Example 3... Example 4... Example 5... Example 6... Deleting Macro Variables... Nested Macros... Additional Debugging Options... GLOBAL and LOCAL Variables... Problem 1... Solution to Problem 1... Problem 2... Solution to Problem 2... Creating READONLY Macro Variables... Determining Whether a Macro Variable Exists... Workshop Session... M5 MACRO PROGRAMMING... Directing Macro Execution... Macro Statements... Macro Comments... Conditional Statements... Debugging Option MLOGIC... AND/OR Logical Operators... Evaluating an Item Against a List of Items... Iteration... Conditional Termination of Macro Flow... %RETURN... %ABORT... String Manipulation... %LENGTH... %UPCASE... %SUBSTR... %INDEX... %SCAN... %SYSFUNC, %QSYSFUNC and %SYSCALL... Example 1 Numeric DATA Step Functions... Example 2 Formatting the Text in a TITLE Statement... Example 3 Check for the Existence of a SAS Data Set... Example 4 Formatting the Date in a TITLE Statement... 2

6 Table of Contents Example 5 Moving a Date Forward... Workshop Session... M6 THE DATA STEP INTERFACE... Functions and Call Routines... SYMGET... Dynamic Change to the Macro Variable Name... Call SYMPUT and Call SYMPUTX... Syntax... Combinations of Form... Example 1 - Data Dependent Titles... Example 2 - Triggering a PROC Based on a DATA Step Value... Example 3 - Sub-Setting a Data Set... Creating a Macro Variable from Proc SQL... Workshop Session... M7 HANDLING SPECIAL CHARACTERS Numeric Evaluations... Explicit Evaluation... Numeric Comparison... Implied Evaluation... Automatic Evaluation... to Quoting Functions... Characters and Operators that Can Be Masked... Why are Quoting Functions Called Quoting Functions?... Rescan or No Rescan?... Compile Time or Execution Time?... Example 1 - Using Quoting Functions to Mask Semicolons at Compilation Time... Example 2 - Using Quoting Functions to Mask % and & Characters at Compilation Time... Example 3 - Using Quoting Functions to Mask Mnemonic Operators at Compilation Time... Example 4 - Using Quoting Functions to Mask Mnemonic Operators at Execution Time... Example 5 - Using Quoting Functions to Work with Unbalanced Quotation Marks or Parentheses at Compilation Time... Example 6 - Using Quoting functions to work with Unbalanced Quotation Marks at Compilation and Execution Time... Built-in Quoting... Summary... Comparison of Quoting Functions... Workshop Session... M8 WORKING WITH MACROS... Using the %INCLUDE Statement... The Autocall Library... The Autocall Facility... Aggregate Storage Locations... Enabling Autocall... 3

7 Table of Contents The Supplied Library... The Stored Compiled Macro Facility... Storing Macros as Catalog Source Entries (Optional)... How SAS Resolves Macro Calls... Writing Successful Macros... Modularity... Referencing Environments... Design... Code Layout... Robustness... Documentation... Efficiency... Maintenance... Workshop Session... WORKSHOP SOLUTIONS... M1 Exercise 1... M1 Exercise 2... M1 Exercise 3... M1 Exercise 4... M1 Exercise 5... M2 Exercise 1... M2 Exercise 2... M2 Exercise 3... M2 Exercise 4... M2 Exercise 5... M2 Exercise 6... M2 Exercise 7... M2 Exercise 8... M3 Exercise 1... M3 Exercise 2... M3 Exercise 3... M3 Exercise 4... M3 Exercise 5... M4 Exercise 1... M4 Exercise 2... M4 Exercise 3... M5 Exercise 1... M5 Exercise 2... M5 Exercise 3... M5 Exercise 4... M5 Exercise 5... M5 Exercise 6... M5 Exercise 7... M6 Exercise 1... M6 Exercise 2... M6 Exercise 3... M6 Exercise 4... M6 Exercise 5... M6 Exercise 6... M6 Exercise 7... M7 Exercise 1... M7 Exercise 2... M7 Exercise 3... M7 Exercise

8 Table of Contents M7 Exercise 5... M7 Exercise 6... M7 Exercise 7... M8... 5

9 Table of Contents 6

10 M1 Common Coding Tasks General Strategy Workshop Session 1-1

11 1-2

12 Common Coding Tasks Those with some experience in SAS DATA and procedure step programming may have come across several classic problems during the course of their work. Example 1 How would you include the current date in the title of a report? In order to do so, you would have to be able to write a TITLE statement that could somehow extract the current date from the system clock. Here is a first attempt at a variable title statement: And not surprisingly, the output starts as: Not very successful! 1-3

13 The macro solution: You can use several automatic macro variables. Automatic implies that the macro variable is available to you when you are running SAS programs. Example 2 As a second example, suppose you want to execute some code conditionally, based upon the day of the week. You may want to execute different steps dependent upon the results of tests. The code below will NOT work because step types are being mixed: 1-4

14 You cannot mix DATA steps and PROC steps in a SAS program. They have to be separate and only the macro language can pass values from one step to another. 1-5

15 For example: 1-6

16 Example 3 In this third example, suppose you have a monthly series of twelve files all to be run with the same report. In this case our 'wrong' attempt may look something like: Here we are assuming our twelve SAS data sets are called MDATA.DS_1 to MDATA.DS_12. This again, will not work because of the attempt to mix steps. We could write 12 individual Proc TABULATE steps however. This alternative solution creates a bundle of code called a macro which will pass a different value to the Proc TABULATE code each time round the loop. 1-7

17 Example 4 (Optional - SAS/Graph users) The fourth example again shows data dependency. Suppose we wish to plot some data and place across it a reference line whose value is dependent on the data. The data set used in the next example is the EPIDEMIC data set. This contains the number of influenza cases reported per week for five age ranges of the population (categories A to E). For category A we wish to plot the number of reported cases against the date (in this case a running week number), but to place across the plot a reference line referring to the average number of cases reported over the period. Our attempt may look like this: Here the intermediate SAS data set called NEWDATA contains the variable AVNUM for all observations, but unfortunately a syntax error results as the VREF option demands an explicit value. 1-8

18 Here is the syntax error caused by using a variable name with the VREF option: Macro again can offer us a solution as a macro variable can resolve to an explicit value. 1-9

19 1-10

20 General Strategy By now you will have noticed the key symbols within the macro language are the ampersand (&) and the percent sign (%). Before we look at the effect of these two symbols, let us consider the progress of a normal DATA step program. This program has one step; a DATA step. The SAS Supervisor places all of these statements in a program input stack, takes one word at a time from the stack and passes them to the SAS compiler or procedure parser (if the step is a proc). At the end of the statement when a semi-colon is reached the statement is checked for syntax. At a step boundary, this process is halted and the step is compiled or parsed, then executed. TOP OF STACK data defines a step boundary run defines a step boundary data new_demog; set mdata.demog; if age > 35 then newsal=salary*1.05; else newsal=salary*1.01; run; 1-11

21 A SAS program is simply a sequence of DATA and PROC steps Each step is delimited by the keywords such as: DATA PROC RUN QUIT ENDSAS A 'word' (or 'token') at a time is transferred to the DATA step compiler or procedure parser. TOP OF STACK data defines a step boundary run defines a step boundary data new_demog; set mdata.demog; if age > 35 then newsal=salary*1.05; else newsal=salary*1.01; run; SAS SUPERVISOR SAS Compiler or Procedure Parser data First Token passed through data new_demog Next Token passed through data new_demog; Checked for Syntax 1-12

22 TOP OF STACK data defines a step boundary run defines a step boundary data new_demog; set mdata.demog; if age > 35 then newsal=salary*1.05; else newsal=salary*1.01; run; SAS SUPERVISOR SAS Compiler or Procedure Parser data new_demog; set and so on, until the RUN; step boundary is found. Upon a step boundary, the SAS Supervisor suspends processing the SAS statements and the completed step is compiled (or parsed in the case of a procedure) and then executed. Each step independently compiles (parses) and then executes. 1-13

23 A SAS program is, and can only be, a series of DATA and PROC steps plus any global statements. The role of Macro is simply to generate code that is to be put on top of the program input stack. TOP OF STACK &sysdate"; proc print data=mdata.policies; var polnum policy; where type='life'; run; SAS SUPERVISOR MACRO SAS Compiler or Procedure Parser title "Job run on The presence of the & followed by a non-blank character triggers the macro facility. The token is passed to the macro facility, which substitutes a value on the input stack. 1-14

24 The value of the macro variable is retrieved by the macro facility and placed on the input stack: TOP OF STACK 26JUN17"; proc print data=mdata.policies; var polnum policy; where type='life'; run; SAS SUPERVISOR MACRO SAS Compiler or Procedure Parser title "Job run on Whereupon, the replaced code is treated as normal: TOP OF STACK "; proc print data=mdata.policies; var polnum policy; where type='life'; run; SAS SUPERVISOR MACRO SAS Compiler or Procedure Parser title "Job run on 26JUN

25 So, the SAS macro facility is concerned with extending and customising the SAS language. It gives users the ability to: Generate code dynamically; Handle text string substitution within code; Enable repeated execution of code bundles; Use conditional logic to execute code. It should be stressed that the SAS macro facility will not enable SAS code to run quicker, but rather produce SAS programs that are potentially re-usable, dynamic and can be maintained more easily. 1-16

Introduction. Getting Started with the Macro Facility CHAPTER 1

Introduction. Getting Started with the Macro Facility CHAPTER 1 1 CHAPTER 1 Introduction Getting Started with the Macro Facility 1 Replacing Text Strings Using Macro Variables 2 Generating SAS Code Using Macros 3 Inserting Comments in Macros 4 Macro Definition Containing

More information

SAS Macro Language: Reference

SAS Macro Language: Reference SAS Macro Language: Reference INTRODUCTION Getting Started with the Macro Facility This is the macro facility language reference for the SAS System. It is a reference for the SAS macro language processor

More information

Base and Advance SAS

Base and Advance SAS Base and Advance SAS BASE SAS INTRODUCTION An Overview of the SAS System SAS Tasks Output produced by the SAS System SAS Tools (SAS Program - Data step and Proc step) A sample SAS program Exploring SAS

More information

Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi

Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi Contents Part 1 Acknowledgments xi Preface xiii About the Author xv About This Book xvii New in the Macro Language xxi Macro Basics Chapter 1 Introduction 3 1.1 Macro Facility Overview 3 1.2 Terminology

More information

Understanding the Concepts and Features of Macro Programming 1

Understanding the Concepts and Features of Macro Programming 1 Contents Preface ix Acknowledgments xi Part 1 Understanding the Concepts and Features of Macro Programming 1 Chapter 1 Introduction 3 What Is the SAS Macro Facility? 4 What Are the Advantages of the SAS

More information

CHAPTER 7 Using Other SAS Software Products

CHAPTER 7 Using Other SAS Software Products 77 CHAPTER 7 Using Other SAS Software Products Introduction 77 Using SAS DATA Step Features in SCL 78 Statements 78 Functions 79 Variables 79 Numeric Variables 79 Character Variables 79 Expressions 80

More information

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

Going Under the Hood: How Does the Macro Processor Really Work? Going Under the Hood: How Does the Really Work? ABSTRACT Lisa Lyons, PPD, Inc Hamilton, NJ Did you ever wonder what really goes on behind the scenes of the macro processor, or how it works with other parts

More information

Journey to the center of the earth Deep understanding of SAS language processing mechanism Di Chen, SAS Beijing R&D, Beijing, China

Journey to the center of the earth Deep understanding of SAS language processing mechanism Di Chen, SAS Beijing R&D, Beijing, China Journey to the center of the earth Deep understanding of SAS language processing Di Chen, SAS Beijing R&D, Beijing, China ABSTRACT SAS is a highly flexible and extensible programming language, and a rich

More information

Introduction to the SAS Macro Facility

Introduction to the SAS Macro Facility Introduction to the SAS Macro Facility Uses for SAS Macros The macro language allows for programs that are dynamic capable of selfmodification. The major components of the macro language include: Macro

More information

More About SAS Macros

More About SAS Macros More About SAS Macros (Than You Thought Possible) Donald P. Gallogly DCBS IMD Topics The SAS Macros System Macro Variables Writing Macros The SAS Macros System The SAS Macros System SAS macros and macro

More information

SAS CURRICULUM. BASE SAS Introduction

SAS CURRICULUM. BASE SAS Introduction SAS CURRICULUM BASE SAS Introduction Data Warehousing Concepts What is a Data Warehouse? What is a Data Mart? What is the difference between Relational Databases and the Data in Data Warehouse (OLTP versus

More information

Advanced Macro Topics Steven First, Systems Seminar Consultants, Madison, WI

Advanced Macro Topics Steven First, Systems Seminar Consultants, Madison, WI Paper 19-26 Advanced Macro Topics Steven First, Systems Seminar Consultants, Madison, WI Abstract The SAS macro language continues to be an integral part of the SAS system, and can be a wonderful tool

More information

Basic Macro Processing Prepared by Destiny Corporation

Basic Macro Processing Prepared by Destiny Corporation Basic Macro Processing Prepared by Destiny Corporation Macro variables In this module we discuss the first of the two special characters - the ampersand (&). When the SAS Supervisor sees an ampersand followed

More information

Surviving the SAS Macro Jungle by Using Your Own Programming Toolkit Kevin Russell, SAS Institute Inc., Cary, North Carolina

Surviving the SAS Macro Jungle by Using Your Own Programming Toolkit Kevin Russell, SAS Institute Inc., Cary, North Carolina PharmaSUG 2016 Paper BB11 Surviving the SAS Macro Jungle by Using Your Own Programming Toolkit Kevin Russell, SAS Institute Inc., Cary, North Carolina ABSTRACT Almost every night there is a reality show

More information

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

Foundations and Fundamentals. SAS System Options: The True Heroes of Macro Debugging Kevin Russell and Russ Tyndall, SAS Institute Inc. SAS System Options: The True Heroes of Macro Debugging Kevin Russell and Russ Tyndall, SAS Institute Inc., Cary, NC ABSTRACT It is not uncommon for the first draft of any macro application to contain errors.

More information

DSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017

DSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017 DSCI 325: Handout 15 Introduction to SAS Macro Programming Spring 2017 The Basics of the SAS Macro Facility Macros are used to make SAS code more flexible and efficient. Essentially, the macro facility

More information

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

title1 Visits at &string1; proc print data=hospitalvisits; where sitecode=&string1; PharmaSUG 2012 Paper TF01 Macro Quoting to the Rescue: Passing Special Characters Mary F. O. Rosenbloom, Edwards Lifesciences LLC, Irvine, CA Art Carpenter, California Occidental Consultants, Anchorage,

More information

SAS Certification Handout #11: Adv. Prog. Ch. 9-10

SAS Certification Handout #11: Adv. Prog. Ch. 9-10 SAS Certification Handout #11: Adv. Prog. Ch. 9-10 /************ Ch. 9 ********************/ /* SAS Macros -- like writing your own functions in SAS; especially useful for reproducing analyses or reports

More information

An Introduction to SAS Macros

An Introduction to SAS Macros An Introduction to SAS Macros Expanded token SAS Program (Input Stack) SAS Wordscanner (Tokenization) Non-Macro (Tokens) SAS Compiler % and & Triggers Macro Facility Steven First, President 2997 Yarmouth

More information

Sandra Hendren Health Data Institute

Sandra Hendren Health Data Institute INTRODUCTION TO THE MACRO LANGUAGE Sandra Hendren Health Data Institute The purpose of this paper is to explain the macro language at a conceptual level. It will not discuss the syntax of the language

More information

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

SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD ABSTRACT CODERS CORNER SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD The SAS Macro Facility offers a mechanism

More information

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

Macro Basics. Introduction. Defining and Using Macro Variables. Defining and Using Macros. Macro Parameters. Part 1. Chapter 1. Chapter 2. Part 1 Macro Basics Chapter 1 Chapter 2 Chapter 3 Chapter 4 Introduction Defining and Using Macro Variables Defining and Using Macros Macro Parameters 2 Carpenter s Complete Guide to the SAS Macro Language

More information

My Enterprise Guide David Shannon, Amadeus Software Limited, UK

My Enterprise Guide David Shannon, Amadeus Software Limited, UK Paper 169-31 My Enterprise Guide David Shannon, Amadeus Software Limited, UK ABSTRACT Following on from My Computer and My Documents, users of SAS can now also have My Enterprise Guide! The aim of this

More information

A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX

A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX South Central SAS Users Group 2016 A Time Saver for All: A SAS Toolbox Philip Jou, Baylor University, Waco, TX ABSTRACT SAS Macros are a useful tool to any SAS Programmer. A macro variable can be used

More information

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

SAS 9 Programming Enhancements Marje Fecht, Prowerk Consulting Ltd Mississauga, Ontario, Canada 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

More information

The Ins and Outs of %IF

The Ins and Outs of %IF Paper 1135-2017 The Ins and Outs of %IF M. Michelle Buchecker, ThotWave Technologies, LLC. ABSTRACT Have you ever had your macro code not work and you couldn't figure out why? Even something as simple

More information

QUEST Procedure Reference

QUEST Procedure Reference 111 CHAPTER 9 QUEST Procedure Reference Introduction 111 QUEST Procedure Syntax 111 Description 112 PROC QUEST Statement Options 112 Procedure Statements 112 SYSTEM 2000 Statement 114 ECHO ON and ECHO

More information

Unlock SAS Code Automation with the Power of Macros

Unlock SAS Code Automation with the Power of Macros SESUG 2015 ABSTRACT Paper AD-87 Unlock SAS Code Automation with the Power of Macros William Gui Zupko II, Federal Law Enforcement Training Centers SAS code, like any computer programming code, seems to

More information

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

SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD Paper BB-7 SAS Macro Dynamics - From Simple Basics to Powerful Invocations Rick Andrews, Office of the Actuary, CMS, Baltimore, MD ABSTRACT The SAS Macro Facility offers a mechanism for expanding and customizing

More information

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

Macro Internals for the User Developer s Overview. Susan O Connor, SAS Institute Inc., Cary, NC Macro Internals for the User Developer s Overview Susan O Connor, SAS Institute Inc., Cary, NC ABSTRACT You have used the macro language software that is part of base software from SAS Institute Inc. or

More information

Simplifying Your %DO Loop with CALL EXECUTE Arthur Li, City of Hope National Medical Center, Duarte, CA

Simplifying Your %DO Loop with CALL EXECUTE Arthur Li, City of Hope National Medical Center, Duarte, CA PharmaSUG 2017 BB07 Simplifying Your %DO Loop with CALL EXECUTE Arthur Li, City of Hope National Medical Center, Duarte, CA ABSTRACT One often uses an iterative %DO loop to execute a section of a macro

More information

Macro Bugs - How to Create, Avoid and Destroy Them Ian Whitlock, Kennett Square, PA

Macro Bugs - How to Create, Avoid and Destroy Them Ian Whitlock, Kennett Square, PA Paper TU-13 Macro Bugs - How to Create, Avoid and Destroy Them Ian Whitlock, Kennett Square, PA ABSTRACT The central theme of this paper is the macro debugging process. However, a great many bugs are simply

More information

Efficiency Programming with Macro Variable Arrays

Efficiency Programming with Macro Variable Arrays ABSTRACT MWSUG 2018 - Paper SP-062 Efficiency Programming with Macro Variable Arrays Veronica Renauldo, QST Consultations, LTD, Allendale, MI Macros in themselves boost productivity and cut down on user

More information

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

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently. 255 APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software Introduction 255 Generating a QMF Export Procedure 255 Exporting Queries from QMF 257 Importing QMF Queries into Query and Reporting 257 Alternate

More information

&&&, ;;, and Other Hieroglyphics Advanced Macro Topics Chris Yindra, C. Y. Training Associates

&&&, ;;, and Other Hieroglyphics Advanced Macro Topics Chris Yindra, C. Y. Training Associates &&&, ;;, and Other Hieroglyphics Advanced Macro Topics Chris Yindra, C. Y. Training Associates INTRODUCTION SAS macros are powerful tools that can create reusable code modules to do a variety of programming

More information

GET A GRIP ON MACROS IN JUST 50 MINUTES! Arthur Li, City of Hope Comprehensive Cancer Center, Duarte, CA

GET A GRIP ON MACROS IN JUST 50 MINUTES! Arthur Li, City of Hope Comprehensive Cancer Center, Duarte, CA GET A GRIP ON MACROS IN JUST 50 MINUTES! Arthur Li, City of Hope Comprehensive Cancer Center, Duarte, CA ABSTRACT The SAS macro facility, which includes macro variables and macro programs, is the most

More information

SAS Macro Programming for Beginners

SAS Macro Programming for Beginners ABSTRACT SAS Macro Programming for Beginners Lora D. Delwiche, Winters, CA Susan J. Slaughter, Avocet Solutions, Davis, CA Macro programming is generally considered an advanced topic. But, while macros

More information

AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, School of Public Health

AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, School of Public Health AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike Zdeb, University@Albany School of Public Health INTRODUCTION There are a number of SAS tools that you may never have to use. Why? The main reason

More information

An Animated Guide: An Introduction to SAS Macro Quoting Russ Lavery Bryn Mawr, PA

An Animated Guide: An Introduction to SAS Macro Quoting Russ Lavery Bryn Mawr, PA An Animated Guide: An Introduction to SAS Macro Quoting Russ Lavery Bryn Mawr, PA Figure 1 ABSTRACT This paper builds on a NESUG 2002 paper that described the general functioning of the SAS Macro Processor.

More information

SURVIVING THE SAS MACRO JUNGLE BY USING YOUR OWN PROGRAMMING TOOLKIT

SURVIVING THE SAS MACRO JUNGLE BY USING YOUR OWN PROGRAMMING TOOLKIT PharmaSUG 2016 Paper BB11 SURVIVING THE SAS MACRO JUNGLE BY USING YOUR OWN PROGRAMMING TOOLKIT KEVIN RUSSELL Photo credit: Geoff Gallice / CC by 2.0 TOOLS FOR YOUR MACRO PROGRAMMING TOOLKIT The DOSUBL

More information

Program Validation: Logging the Log

Program Validation: Logging the Log Program Validation: Logging the Log Adel Fahmy, Symbiance Inc., Princeton, NJ ABSTRACT Program Validation includes checking both program Log and Logic. The program Log should be clear of any system Error/Warning

More information

HOW TO DEVELOP A SAS/AF APPLICATION

HOW TO DEVELOP A SAS/AF APPLICATION PS001 Creating Effective Graphical User Interfaces Using Version 8 SAS/AF Anders Longthorne, National Highway Traffic Safety Administration, Washington, DC ABSTRACT Improving access to an organization

More information

MOBILE MACROS GET UP TO SPEED SOMEWHERE NEW FAST Author: Patricia Hettinger, Data Analyst Consultant Oakbrook Terrace, IL

MOBILE MACROS GET UP TO SPEED SOMEWHERE NEW FAST Author: Patricia Hettinger, Data Analyst Consultant Oakbrook Terrace, IL MOBILE MACROS GET UP TO SPEED SOMEWHERE NEW FAST Author: Patricia Hettinger, Data Analyst Consultant Oakbrook Terrace, IL ABSTRACT: Have you ever been faced with this scenario? It s your first day on the

More information

SAS Online Training: Course contents: Agenda:

SAS Online Training: Course contents: Agenda: SAS Online Training: Course contents: Agenda: (1) Base SAS (6) Clinical SAS Online Training with Real time Projects (2) Advance SAS (7) Financial SAS Training Real time Projects (3) SQL (8) CV preparation

More information

Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board

Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board INTRODUCTION In 25 years as a SAS consultant at the Federal Reserve Board, I have seen SAS users

More information

Using Data Transfer Services

Using Data Transfer Services 103 CHAPTER 16 Using Data Transfer Services Introduction 103 Benefits of Data Transfer Services 103 Considerations for Using Data Transfer Services 104 Introduction For many applications, data transfer

More information

A Tutorial on the SAS Macro Language

A Tutorial on the SAS Macro Language HW152 SESUG 2015 A Tutorial on the SAS Macro Language John J. Cohen, Advanced Data Concepts LLC, Newark, DE ABSTRACT The SAS Macro language is another language that rests on top of regular SAS code. If

More information

STATION

STATION ------------------------------STATION 1------------------------------ 1. Which of the following statements displays all user-defined macro variables in the SAS log? a) %put user=; b) %put user; c) %put

More information

An Introduction to Macros Deb Cassidy

An Introduction to Macros Deb Cassidy Paper #HW03 An Introduction to Macros Deb Cassidy Abstract A search in the proceedings for SUGI 24-28 for the word "macro" had over 1,000 hits. Why are macros so popular? A quick glance through the papers

More information

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

Paper ###-YYYY. SAS Enterprise Guide: A Revolutionary Tool! Jennifer First, Systems Seminar Consultants, Madison, WI Paper ###-YYYY SAS Enterprise Guide: A Revolutionary Tool! Jennifer First, Systems Seminar Consultants, Madison, WI ABSTRACT Whether you are a novice or a pro with SAS, Enterprise Guide has something for

More information

Tired of CALL EXECUTE? Try DOSUBL

Tired of CALL EXECUTE? Try DOSUBL ABSTRACT SESUG Paper BB-132-2017 Tired of CALL EXECUTE? Try DOSUBL Jueru Fan, PPD, Morrisville, NC DOSUBL was first introduced as a function in SAS V9.3. It enables the immediate execution of SAS code

More information

The SAS Interface to REXX

The SAS Interface to REXX 95 CHAPTER 9 The SAS Interface to REXX Overview 95 The Subcommand Environment 96 Retrieving and Assigning the Values of REXX Variables in a SAS Program 97 Using the GETEXEC DATA Step Function 97 Using

More information

Customising SAS OQ to Provide Business Specific Testing of SAS Installations and Updates

Customising SAS OQ to Provide Business Specific Testing of SAS Installations and Updates Paper TS07 Customising SAS OQ to Provide Business Specific Testing of SAS Installations and Updates Steve Huggins, Amadeus Software Limited, Oxford, UK ABSTRACT The SAS Installation Qualification and Operational

More information

Jeff Phillips, ARC Professional Services Group Veronica Walgamotte, ARC Professional Services Group Derek Drummond, ARC Professional Services Group

Jeff Phillips, ARC Professional Services Group Veronica Walgamotte, ARC Professional Services Group Derek Drummond, ARC Professional Services Group ~- WARNING: ApPARENT MACRO INVOCATION NOT RESOLVED TECHNIQUES FOR DEBUGGING MACRO CODE Jeff Phillips, ARC Professional Services Group Veronica Walgamotte, ARC Professional Services Group Derek Drummond,

More information

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS TO SAS NEED FOR SAS WHO USES SAS WHAT IS SAS? OVERVIEW OF BASE SAS SOFTWARE DATA MANAGEMENT FACILITY STRUCTURE OF SAS DATASET SAS PROGRAM PROGRAMMING LANGUAGE ELEMENTS OF THE SAS LANGUAGE RULES FOR SAS

More information

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

BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS. What is SAS History of SAS Modules available SAS SAS COURSE CONTENT Course Duration - 40hrs BASICS BEFORE STARTING SAS DATAWAREHOSING Concepts What is ETL ETL Concepts What is OLAP SAS What is SAS History of SAS Modules available SAS GETTING STARTED

More information

COMPILER DESIGN LECTURE NOTES

COMPILER DESIGN LECTURE NOTES COMPILER DESIGN LECTURE NOTES UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing:

More information

Functions vs. Macros: A Comparison and Summary

Functions vs. Macros: A Comparison and Summary Functions vs. Macros: A Comparison and Summary Mahipal Vanam Phaneendhar Vanam Srinivas Vanam Percept Pharma Services, Bridgewater, NJ ABSTRACT SAS is rich in various built-in functions, and predefined

More information

Seminar Series: CTSI Presents

Seminar Series: CTSI Presents Biostatistics, Epidemiology & Research Design (BERD) Howard Cabral, PhD, MPH Christine Chaisson, MPH Seminar Series: CTSI Presents November 20, 2014 Demystifying SAS Macros BUSPH Data Coordinating Center

More information

SAS Macro Language 1: Essentials. Course Notes

SAS Macro Language 1: Essentials. Course Notes SAS Macro Language 1: Essentials Course Notes SAS Macro Language 1: Essentials Course Notes was developed by Jim Simon and Linda Mitterling. Additional contributions were made by Davetta Dunlap, John McCall,

More information

No, it's not magic: De-mystifying the SAS Macro Facility Jay A. Jaffe, PhD

No, it's not magic: De-mystifying the SAS Macro Facility Jay A. Jaffe, PhD No, it's not magic: De-mystifying the SAS Macro Facility Jay A. Jaffe, PhD ABSTRACT To get the most out of SAS macros and macro variables, you must know how the Macro environment interacts with the SAS

More information

Your Own SAS Macros Are as Powerful as You Are Ingenious

Your Own SAS Macros Are as Powerful as You Are Ingenious Paper CC166 Your Own SAS Macros Are as Powerful as You Are Ingenious Yinghua Shi, Department Of Treasury, Washington, DC ABSTRACT This article proposes, for user-written SAS macros, separate definitions

More information

Exploring the SAS Macro Function %SYSFUNC

Exploring the SAS Macro Function %SYSFUNC Paper CC11 Exploring the SAS Macro Function %SYSFUNC Lin Yan and Helen Wang Department of Scientific Programming Merck Research Labs, Merck & Co., Inc. Rahway, New Jersey 07065 ABSTRACT The SAS macro function

More information

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

SAS Programming Techniques for Manipulating Metadata on the Database Level Chris Speck, PAREXEL International, Durham, NC PharmaSUG2010 - Paper TT06 SAS Programming Techniques for Manipulating Metadata on the Database Level Chris Speck, PAREXEL International, Durham, NC ABSTRACT One great leap that beginning and intermediate

More information

Contents. About This Book...1

Contents. About This Book...1 Contents About This Book...1 Chapter 1: Basic Concepts...5 Overview...6 SAS Programs...7 SAS Libraries...13 Referencing SAS Files...15 SAS Data Sets...18 Variable Attributes...21 Summary...26 Practice...28

More information

SAS Institute Exam A SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ]

SAS Institute Exam A SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ] s@lm@n SAS Institute Exam A00-212 SAS Advanced Programming Version: 6.0 [ Total Questions: 184 ] Question No : 1 The report will not successfully run and will produce an error message in the log. What

More information

Extending the Scope of Custom Transformations

Extending the Scope of Custom Transformations Paper 3306-2015 Extending the Scope of Custom Transformations Emre G. SARICICEK, The University of North Carolina at Chapel Hill. ABSTRACT Building and maintaining a data warehouse can require complex

More information

Chapter 7 File Access. Chapter Table of Contents

Chapter 7 File Access. Chapter Table of Contents Chapter 7 File Access Chapter Table of Contents OVERVIEW...105 REFERRING TO AN EXTERNAL FILE...105 TypesofExternalFiles...106 READING FROM AN EXTERNAL FILE...107 UsingtheINFILEStatement...107 UsingtheINPUTStatement...108

More information

%MISSING: A SAS Macro to Report Missing Value Percentages for a Multi-Year Multi-File Information System

%MISSING: A SAS Macro to Report Missing Value Percentages for a Multi-Year Multi-File Information System %MISSING: A SAS Macro to Report Missing Value Percentages for a Multi-Year Multi-File Information System Rushi Patel, Creative Information Technology, Inc., Arlington, VA ABSTRACT It is common to find

More information

Why & How To Use SAS Macro Language: Easy Ways To Get More Value & Power from Your SAS Software Tools

Why & How To Use SAS Macro Language: Easy Ways To Get More Value & Power from Your SAS Software Tools Why & How To Use SAS Macro Language: Easy Ways To Get More Value & Power from Your SAS Software Tools LeRoy Bessler PhD Bessler Consulting and Research Strong Smart Systems Mequon, WI, USA Le_Roy_Bessler@wi.rr.com

More information

UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing: A preprocessor may allow a

More information

Using Macro Functions

Using Macro Functions Using Macro Functions Arthur L. Carpenter California Occidental Consultants ABSTRACT Many macro functions are very analogous to those of the DATA step. The differences are in how they are used and applied.

More information

Macro Quoting: Which Function Should We Use? Pengfei Guo, MSD R&D (China) Co., Ltd., Shanghai, China

Macro Quoting: Which Function Should We Use? Pengfei Guo, MSD R&D (China) Co., Ltd., Shanghai, China PharmaSUG China 2016 - Paper 81 Macro Quoting: Which Function Should We Use? Pengfei Guo, MSD R&D (China) Co., Ltd., Shanghai, China ABSTRACT There are several macro quoting functions in SAS and even some

More information

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

Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility Macros from Beginning to Mend A Simple and Practical Approach to the SAS Macro Facility Michael G. Sadof, MGS Associates, Inc., Bethesda, MD. ABSTRACT The macro facility is an important feature of the

More information

Paper 149 JAY A. JAFFE

Paper 149 JAY A. JAFFE SAS MACROS BEYOND THE BASICS JAY A. JAFFE So you got some %LET statements, some &symbols, and maybe some %MACROs that help you do your work? Let s go ahead and leverage the full power of the SAS Macro

More information

PLA YING WITH MACROS: TAKE THE WORK OUT OF LEARNING TO DO MACROS. Arthur L. Carpenter

PLA YING WITH MACROS: TAKE THE WORK OUT OF LEARNING TO DO MACROS. Arthur L. Carpenter PLA YING WITH MACROS: TAKE THE WORK OUT OF LEARNING TO DO MACROS Arthur L. Carpenter ABSTRACT The macro language can add an additional level of complexity to programs written in SAS~. Macro statements

More information

New Macro Features Added in SAS 9.3 and SAS 9.4

New Macro Features Added in SAS 9.3 and SAS 9.4 SAS1575-2015 New Macro Features Added in SAS 9.3 and SAS 9.4 Richard D. Langston, SAS Institute Inc. ABSTRACT This paper describes the new features added to the macro facility in SAS 9.3 and SAS 9.4. New

More information

Contents. Overview How SAS processes programs Compilation phase Execution phase Debugging a DATA step Testing your programs

Contents. Overview How SAS processes programs Compilation phase Execution phase Debugging a DATA step Testing your programs SAS Data Step Contents Overview How SAS processes programs Compilation phase Execution phase Debugging a DATA step Testing your programs 2 Overview Introduction This section teaches you what happens "behind

More information

Files Arriving at an Inconvenient Time? Let SAS Process Your Files with FILEEXIST While You Sleep

Files Arriving at an Inconvenient Time? Let SAS Process Your Files with FILEEXIST While You Sleep Files Arriving at an Inconvenient Time? Let SAS Process Your Files with FILEEXIST While You Sleep Educational Testing Service SAS and all other SAS Institute Inc. product or service names are registered

More information

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

Get Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp. Get Started Writing SAS Macros Luisa Hartman, Jane Liao, Merck Sharp & Dohme Corp. ABSTRACT The SAS Macro Facility is a tool which lends flexibility to your SAS code and promotes easier maintenance. It

More information

Arthur L. Carpenter California Occidental Consultants, Oceanside, California

Arthur L. Carpenter California Occidental Consultants, Oceanside, California Paper 028-30 Storing and Using a List of Values in a Macro Variable Arthur L. Carpenter California Occidental Consultants, Oceanside, California ABSTRACT When using the macro language it is not at all

More information

Inspiring P3O Training

Inspiring P3O Training Inspiring P3O Training About P3O P3O is an acronym of Portfolio Programme and Project Offices. The P3O guidance, through principles, processes and techniques, provides a model for support structures for

More information

DATA Step Debugger APPENDIX 3

DATA Step Debugger APPENDIX 3 1193 APPENDIX 3 DATA Step Debugger Introduction 1194 Definition: What is Debugging? 1194 Definition: The DATA Step Debugger 1194 Basic Usage 1195 How a Debugger Session Works 1195 Using the Windows 1195

More information

SAS System Powers Web Measurement Solution at U S WEST

SAS System Powers Web Measurement Solution at U S WEST SAS System Powers Web Measurement Solution at U S WEST Bob Romero, U S WEST Communications, Technical Expert - SAS and Data Analysis Dale Hamilton, U S WEST Communications, Capacity Provisioning Process

More information

Storing and Reusing Macros

Storing and Reusing Macros 101 CHAPTER 9 Storing and Reusing Macros Introduction 101 Saving Macros in an Autocall Library 102 Using Directories as Autocall Libraries 102 Using SAS Catalogs as Autocall Libraries 103 Calling an Autocall

More information

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! Any questions about the syllabus?! Course Material available at www.cs.unic.ac.cy/ioanna! Next time reading assignment [ALSU07]

More information

SAS Macro Programming Tips and Techniques

SAS Macro Programming Tips and Techniques PharmaSUG 2012 Paper HW05 SAS Macro Programming Tips and Techniques Kirk Paul Lafler, Software Intelligence Corporation, Spring Valley, California Abstract The SAS Macro Language is a powerful feature

More information

An Introduction to SAS/SHARE, By Example

An Introduction to SAS/SHARE, By Example Paper AD01 An Introduction to SAS/SHARE, By Example Larry Altmayer, U.S. Census Bureau, Washington, DC ABSTRACT SAS/SHARE software is a useful tool for allowing several users to access and edit the same

More information

SAS/FSP 9.2. Procedures Guide

SAS/FSP 9.2. Procedures Guide SAS/FSP 9.2 Procedures Guide The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2008. SAS/FSP 9.2 Procedures Guide. Cary, NC: SAS Institute Inc. SAS/FSP 9.2 Procedures

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING PRINCIPLES OF COMPILER DESIGN 2 MARKS UNIT I INTRODUCTION TO COMPILING 1. Define compiler? A compiler is a program that reads a program written in one language (source language) and translates it into

More information

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Introduction: PHP (Hypertext Preprocessor) was invented by Rasmus Lerdorf in 1994. First it was known as Personal Home Page. Later

More information

Vijeo Citect Customization and Design Study Guide

Vijeo Citect Customization and Design Study Guide Vijeo Citect Customization and Design Study Guide Version 7.30 Schneider-Electric Pty (Australia) Ltd 78 Waterloo Road Macquarie Park NSW 2113 Australia DISCLAIMER Schneider Electric makes no representations

More information

Unravelling the Knot of Ampersands

Unravelling the Knot of Ampersands Paper 3285-2015 Unravelling the Knot of Ampersands Joe Matise, NORC at the University of Chicago ABSTRACT We've all heard it before: "If two ampersands don't work, add a third." But how many of us really

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

SAS Macro Design Issues Ian Whitlock, Westat

SAS Macro Design Issues Ian Whitlock, Westat Paper 67-27 SAS Macro Design Issues Ian Whitlock, Westat Abstract Two questions motivated this paper. The first came more than twenty years ago at the end of my first programming course when the professor

More information

SAS Business Rules Manager 1.2

SAS Business Rules Manager 1.2 SAS Business Rules Manager 1.2 User s Guide Second Edition SAS Documentation The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2012. SAS Business Rules Manager 1.2. Cary,

More information

Chapter 1. Introduction. 1.1 More about SQL More about This Book 5

Chapter 1. Introduction. 1.1 More about SQL More about This Book 5 Chapter 1 Introduction 1.1 More about SQL 2 1.2 More about This Book 5 SAS defines Structured Query Language (SQL) as a standardized, widely used language that retrieves data from and updates data in tables

More information

Lecture 1 Getting Started with SAS

Lecture 1 Getting Started with SAS SAS for Data Management, Analysis, and Reporting Lecture 1 Getting Started with SAS Portions reproduced with permission of SAS Institute Inc., Cary, NC, USA Goals of the course To provide skills required

More information

Submitting SAS Code On The Side

Submitting SAS Code On The Side ABSTRACT PharmaSUG 2013 - Paper AD24-SAS Submitting SAS Code On The Side Rick Langston, SAS Institute Inc., Cary NC This paper explains the new DOSUBL function and how it can submit SAS code to run "on

More information

Lesson 1: Writing Your First JavaScript

Lesson 1: Writing Your First JavaScript JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript

More information