The SAS Macro Language. Joy Reel

Size: px
Start display at page:

Download "The SAS Macro Language. Joy Reel"

Transcription

1 The SAS Macro Language Joy Reel The purpose of the SAS macro language tutorial is to give an overview of the language and its capabilities, and to provide some possible uses pertinent to your environment. The last part of the tutorial is a small-scale inte~active system made up of a series of macros to illustrate using the language to build user friendly systems for local use. In general a macro language is a preprocessor. It does its work and passes the results to a compiler or another processor. A single macro is a set of statements that produces as its results some sort of textual output, for example, character strings. The SAS macro language uses programming staterr.ents, keywords, and techniques which very closely resemble the basics of the SAS language itself. The maj or di fference in the two are the identifying % and & used in the macro language. The results of a SAS macro are character strings which form SAS statements or pieces of SAS statements. The SAS macro language uses macro variables, also called symbolics, to alter the generated text from one execution of the macro to another or to provide needed information to the macro. There are many possible uses of the macro facility in SAS. You can replace data set names from run to run by using symbolics or possibly to build a data set name based on different criteria. You can do these things through text replacement and/or text concatenation. Many users have requested the capability to conditionally execute OAT!'. and PRoe steps wi thin SAS, and the macro language offers that ability. The macro progra:nming statements allow a user to test and select steps based on user defined or automatic macro variable values. The actual selection process is done before the code is sent to the SAS compiler and therefore no SAS rules are broken using this approach. You can define parameters with the macro with default or null values. With symbolic substitution the macro execution can produce different results at different times. t " i., f. j: ; t. ~ "" Ii ~ ;,. }, i. ~ ~. ~: With the ability of the macro language to talk to the user and accept his response from a terminal, user friendly interactive systems can be written for use by those who do not know SAS at all. 969

2 %IF &choice=l %THEN %DO; %CHECK(CURRENT) %IF &eof=y %THEN %GO TO ENDIT; PROC CHART DATA=INPUT.CURRENT; VBAR salesman/sumvar=sales; TITLEl Sales for the Month of &date; %PUT end of choicel; %ELSE %IF &choice=2 %THEN %DO; %CHECK(YTD) %IF &eof=y %THEN %GO TO END IT; PROC CHART DATA=INPUT.YTD; VBAR salesman/sumvar=sales; TITLE! Year to Date Sales Through the Month of &date; %ELSE %IF &choice=3 %THEN %DO; %CHECK(CURRENT) %IF &eof~y %THEN %GO TO ENDIT; PROC PRINT DATA=INPUT.CURRENT; VAR salesman sales; TITLEl Monthly Sales Report for the Month of &date; %ENDIT: %M %RUNIT %ELSE %IF &choice=4 %THEN %DO; %CHECK(YTD) %IF &eof=y %THEN %GO TO ENDIT; PROC PRINT DATA=INPUT.YTD; VAR salesman sales; TITLE! Year to Date Report of Sales Through &date; %ELSE %DO; %LET time=l; %ERROR The core of the system is a selection of one of four possible reports - two using PROC PRINT and two using PROC CHART. RUNIT only allows a user one pass if he chooses correctl y the first time, but other looping wi thin the RUNIT macro is possible. Note my use of %PUT as a debugging tool in the &choice=l section. Note also that the SAS compiler sees only one procedure step. The condition is met within the macro and the macro results pass to compiler as only one PROC step. This little mini system is very simple to construct, and uses very basic macros with only one function each. However, the idea can be expanded to write very sophisticated systems which can lead users with no SAS experience to construct SAS programs by responding to questions. 978

3 A MACRO %MACRO LOOP; %DO I = 1 %TO 10; %MEND LOOP; DATA DATA&I; DO X = 1 TO 10; Y = &1 + X; THE CALL This is what a SAS macro definition looks like. The important words here are %MI'.CRO and %MEND which enclose the macro definition. Notice the use of the same syntax in the DO loops. The macro programming language keywords are identical to SAS key words except that they begin with a %. Note that the macro call uses a % in front of the macro name. It does not include a semicolon at the end. %LOOP THE RESULTS r: SAS sees DATA DATAl; DO X = 1 TO 10; Y = I + Xi DATA DATA2; DO X = 1 TO 10; Y = 2 + Xi DATA DATA3; DO X = 1 TO 10; Y = 3 + Xi The result of the execution of macro LOOP indicates that the SAS compiler receives ten data steps as defined by the %DO loop. Note also that if the upper limit had been 1000 instead of 10, the macro would have generated 1000 data steps to be compi led and executed by the 5.1\5 compiler. Be careful.! DATA DATA10; DO X ::; 1 TO 10; Y = 10 + X ;. t 970

4 OPEN CODE DATA; DO X=l TO 10; Y=X+l; %LET A=NOW IS THE TIME; %SORTIT(key) MACRO CODE %IF &A=NOW %THEN %DO... r~o = 1 %TO &NUMBER;... other macro program statements An. important concept of the macro language is that of open code versus macro code. SAS statements themselves, macro calls, and some of the macro keywords such as %LET are used in open code. Most macro key words are used in macro code only, that is, in:side a macro definition. For example, %IF %THEN... ; may only be used inside a macro, not in open code. DATA; %LET MONTH~January; TITLE2 Report for &month; PROC PRINT; Report for January %LET MONTH=February; Using a macro variable or symbolic in a TITLE statement is a common application of the macro facility. However, it is impo~tant to realize that symbolic substitution is done at compile time. In this example, failure to repeat the TITLE2 statement results in using the original value for &month. The actual value of month changed, but substitution had already been done in the TITLE2 statement itse2.f. i: proe print; Report for January 971

5 /* THIS EXAMPLE ILLUSTRATES THE USE OF SYMBOLICS IN A TITLE STATEMENT. NOTE THAT THE TITLE STATEMENT USING THE SYMBOLIC MUST BE REPEATED WH~N THE VALUE OF THE SYMBOLIC IS CHANGED. */ DATA TEST; DO X=l TO 5 %LET NUMBER=FIRST; %LET PAGE=l; TITLEl; TITLE2 THIS IS MY &NUMBER EXAMPLE -- PAGE &PAGE; The next example shows the correct way to handle the problem. Since TITLE2 is repeated the second PROe PRINT output will show the current value of the macro variables in the ti tle. PROC PRINT; RU~; %LET NUMBER=SECONDi %LET PAGE=%EVAL(&PAGE+l); TITLE2 PROC PRINT; Old Style Macro THIS IS MY &NUMBER EXAMPLE -- PAGE &PAGE; MACRO KEEPLIST NAME ADDRESS! ADDRESS2 CITY STATE ZIP; % Reference NEW WAY KEEPLIST %LET KEEPLIST=NAME ADDRESSI ADDRESS2 CITY STATE ZIP; Reference &KEEPLIST Since have many old users macro definitions in current production there needs to code, be a simple way of converting to the new macro faei 1i ty. The new macro facility is nuch more ef'ficient and certainly more flexible for future enhancements to user code. The easiest way to convert from old to new is to use the %LET statement as in this example. If the old style macro consists of more than one statement, then the entire old macro can be enclosed inside a %STR statement so that a semicolon does not signal the end of the %LET. In addition all references to the macro must be changed from the name alone to the name preceded by &. 972

6 PRoe FORMAT; VALUE MONFT l=january 2=Februrary 3=March 4=April 5=May 6=June DATA; INPUT MONTH SALES; LENGTH CNT $ 1 ; CNT~LEFT(_N_I ; CALL SYMPUT( MONTH' I ICNT,PUT(MONTH,MONFT. )); CARDS; data... There is not yet available the ability to format a symbolic variable with a SAS or user defined format. This example illustrates a method of assigning a formatted value to a macro variable so that it will display in the desired format. There is probably a better example in the little interactive system at the end of the tutorial. yields symbolic monthl value January /* THE SORTIT MACRO PERFORMS A SORT WITH THE BY VARIABLE SPECIFIED ON THE MACRO CALL */ %MACRO SORTIT(KEY); PROC SORT; BY &KEY; %MEND SORTIT; We are going to look at some very simple macro definitions to get the feel of the macro language. The SORTIT macro is about as simple as they get, but it does il~ustrate the use of a positional parameter~ It could be used if a user needed to sort a data set several times using a different BY variable each time. Even here we c an see that it is easier to key %SORTIT(NAME) or %SORTIT(ID) than the whole FROe step, and there is less chance for user error. 973

7 %MACRO CHOOSE(N~l,PROCESS~PRINT); %* THIS EXANPLE ALLOWS YOU TO CREATE N DATA SETS AND RUN A PROCEDURE OF YOUR CHOICE ON THE DATA; %IF &N <1 %THEN %DO; %PUT INVALID DATA; %PUT PROCESSING WILL STOP; %ELSE %DO 1=1 %TO &N %BY 1; ~~ DATA; %DO J~l %TO 10- o X=UNIFORM( 0) ; PRoe &PROCESSi The CHOOSE macro i:lustrates the use of key.,.;ord parameters defined with specific default values. It also shows error checking of a passed parameter value. The macro call without parameters %8HOOSE would used the default values as defined on the %MACRO statement. %MEND CHOOSE; /* This macro c~ecks to see which control program the user to running under and sets up temporary space accordingly. */ %MACRO SETUP; %IF &SYSSCP::;::CMS %THEN ~~DO; ems EXEC TD::SK; CMS FILEDEF TEMP DISK D D ~; %MEND SETUP; %ELSE %IF &SYSSCP=OS %THEN %DO; %TSO ALLOC F(TEI1P) SPACE(5 0) NEW; %TSO ALLoe F(MACROIN) DA(' your data set name'); %ELSE-%PUT This macro does not work on your system; There are a number of useful automatic symbollc variables supplied with the macro faci Ii ty to facilitate its use. The SETUP macro checks the SYSSCP variable ~o determine if the user is running under CI"lS or as. If neither is the case, a message is wr i tten to the SAS log. Another simi lar and perhaps more useful symbolic is the SYSENV which tells whether one is in foreground(in~eractive) or background(batch). See the SAS USERS GUIDE: BASICS for more of these. All the automatic symbolics are global variables. 974

8 %MACRO SPACES(LINES); %* This macro writes a number of blank lines to the terminal screen depending on the value of the lines parameter. ; %DO i=l %TO &lines; %PUT %str ( ); %MEND SPACES; The SPACES macro has a very trivial function. It writes a li tera~ blank to the SAS log. Because of the single %PUT and the literal blank, it actual writes a blank line. The number of blank lines it writes is determined by the value of the pesi tien parameter LINES. We will use this later on to make screen as pretty as possible. %MACRO CEECK(WHICH); %* This macro checks for a null data set. If it finds one, it sets a flag and stops. It the data set is not empty, it sets the flag to a different value and crea~es a symbolic to be used la~er in a title.; data _null_; do i=l; if _n_=l and nobs=o then do; call symput(' eof', 'y'); stop; end; else do; call symput( I eo ', 'N'); set input.&which ~oint=i nobs=nobs; call symput('date,put(month,date7. )); stop; end; The CHECK macro looks at a data set to see if it is empty. It uses the data step function SYMP~T to set a flag- with the appl'opl-iate value. If the data set is not empty, it also sets up a symbolic for later use in a title. run; end; %MEND CHECK; 975

9 %MACRO ERROR; %* This macro is called if the user does not enter a valid selection from the list. If it is his first mistake, he gets another chance. Otherwise, he is told to try later.; %SP~.CES (3) ; %IF &time=l %THEN %DO; %PUT You are not paying attention.; %PUT Perhaps you should try again later. %PUT Execution will cease.; %LET bad=l; %ELSE %DO; %LET bad=o; %LET time=l i %PUT You did not follow instructions. ; %PUT Would you like to try again? Y or N? %INPUT again; %IF %UPCASE(&again)=Y %THEN %RUNIT; %ELSE %LET bad=l; %ENDi The ERROR macro is used in case a user response is incorrect according to the choices given him. Symbolic error flags are set and messages are written to the SAS log to give the user additional information about what is going to happen. %MEND ERROR i i.,macro BUFFER; %* This macro checks the automatic symbolic variable S SBUFFR to see if the user entered more information than the prompting maca requested. If so, a message is displayed and execution continues. %IF &SYSBUFFR~= %THEN %DOi %PUT Extra information on input ignored.; %PUT Execution will continue.; %PUT Please be careful to follow instructions.i %MEND BUFFER; The BUFFER macro tests to see if the user entered more information that was requested. If so, he is warned. The automatic variable SYSBUFFR receives all information entered by the user not assigned to a specific symbolic variable. i f %MACRO BAD_RTCD; %* This macro tests for a good return code after execution of a macro or the macro language service routines. In this example it is used to make sure a file allocation was successful.; %IF &SYSRC ~= 0 %THEN %DO: %PUT The file yo~ have chosen is not currently avai~able. %LET bad=l; %ELSE %LET bad=oi %MEND BAD_RTCD; The checks macro SYSRC automatic variable to see if a file allocation was successful. I f not, the user is told and the BAD flag setting signals the outer macro to cease processing. 976

10 %MACRO TALKIT; %* This macro displays the primitive menu user to make his selection and accepts choice. ; for the his %SPACES( 3) %PUT The following monthly reports are available for %PUT you to run; %SPACES( 3) %PUT 1. A chart of monthly sales by salesman.; %SPACES(2) %PUT 2. A year-to-date chart of sales by salesman.; %SPACES(2 ) %PUT 3. A regular monthly report of sales by salesman.; %SPACES(2 ) %PUT 4. A regular monthly report of year-to-date sales %PUT by salesman.; %SPACES(3 ) %PUT Please enter the number of your choice.; %INPUT choice; %MEND TALKIT; The TALKIT macro calls the SPACES macro to write blank lines to the SAS log and gives the user information from which to select certain SAS steps. I t provides a rather primitive menu. I~ also accepts the user's choice from the terminal. Please note that %INPUT does not work in batch. %MACRO RUN!T; %* The RUNrT macro combines all the macros to produce the desired results; %GLOBAL time eof bad choice date; %TALKIT %BUFFER %TSO ALLOe f(input) da('joy.mylib') S3R; %BAD_RTCD %IF &bad;:::l ~'THEN %GOTO ENDlT; The RUNIT macro is the driver macro which puts together the last six examples to build a simple interactive system. The flags which are used in several of the macros are globaled and each macro is called according to its function. The flags are tested in the RUNIT macro so that processing can be halted if something is not right by jumping to a label at the end of the macro. 977

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

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

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

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

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

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

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

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

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

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

CROSSREF Manual. Tools and Utilities Library

CROSSREF Manual. Tools and Utilities Library Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN

More information

BASING AN ECONOMIC INFORMATION SYSTEM ON SAS MARTIN HXRNQVIST AB VOLVO-DATA

BASING AN ECONOMIC INFORMATION SYSTEM ON SAS MARTIN HXRNQVIST AB VOLVO-DATA BASING AN ECONOMIC INFORMATION SYSTEM ON SAS MARTIN HXRNQVIST AB VOLVO-DATA At Volvo SAS is used in many different applications: as a tool for computer performance analysis, as a report generator in COBOL-systems,

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

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

An Introduction to SAS Macros Steven First, Systems Seminar Consultants, Madison, WI

An Introduction to SAS Macros Steven First, Systems Seminar Consultants, Madison, WI Paper 153-26 An Introduction to SAS Macros Steven First, Systems Seminar Consultants, Madison, WI Abstract The SAS programming language has a rich tool-box of features that can offer a lot of power to

More information

CA-View Extract User Dialog

CA-View Extract User Dialog CA-View Extract User Dialog A User Friendly ISPF Interface to CA-View Reports Version 1.19 Revised June 16, 2003 Lionel B. Dyck Kaiser Permanente Information Technology 25 N. Via Monte Ave Walnut Creek,

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

COSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22

COSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22 COSC 2P91 Bringing it all together... Week 4b Brock University Brock University (Week 4b) Bringing it all together... 1 / 22 A note on practicality and program design... Writing a single, monolithic source

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

rc = libname( mylib, /nosuch ); if rc ne 0 then %fatal; OR if libname( mylib, /nosuch ) then %fatal; Select (flag); when (1) when (2) otherwise %fatal(text= Unexpected flag value, syscodes=n); end; %macro

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

Chapter 4 - Notes Control Structures I (Selection)

Chapter 4 - Notes Control Structures I (Selection) Chapter 4 - Notes Control Structures I (Selection) I. Control Structures A. Three Ways to Process a Program 1. In Sequence: Starts at the beginning and follows the statements in order 2. Selectively (by

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 03: Program Development Life Cycle Readings: Not Covered in Textbook Program Development

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

PharmaSUG Paper PO12

PharmaSUG Paper PO12 PharmaSUG 2015 - Paper PO12 ABSTRACT Utilizing SAS for Cross-Report Verification in a Clinical Trials Setting Daniel Szydlo, Fred Hutchinson Cancer Research Center, Seattle, WA Iraj Mohebalian, Fred Hutchinson

More information

David S. Septoff Fidia Pharmaceutical Corporation

David S. Septoff Fidia Pharmaceutical Corporation 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

More information

UNIT-IV: MACRO PROCESSOR

UNIT-IV: MACRO PROCESSOR UNIT-IV: MACRO PROCESSOR A Macro represents a commonly used group of statements in the source programming language. A macro instruction (macro) is a notational convenience for the programmer o It allows

More information

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives

More information

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

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ Paper CC16 Smoke and Mirrors!!! Come See How the _INFILE_ Automatic Variable and SHAREBUFFERS Infile Option Can Speed Up Your Flat File Text-Processing Throughput Speed William E Benjamin Jr, Owl Computer

More information

<:ards,. The SAS" Macro: An Aid to the User 3' pfbl:me~~&j1tbc(lpt; 2435 procopt; RESOLVED RESOLVED

<:ards,. The SAS Macro: An Aid to the User 3' pfbl:me~~&j1tbc(lpt; 2435 procopt; RESOLVED RESOLVED The SAS" Macro: An Aid to the User Robert E. Johnson Department of Mathematical Sciences, Virginia Commonwealth University, Richmond, VA23284-2014 This paper is presented as a beginning tutorial on the

More information

Buffer Manager: Project 1 Assignment

Buffer Manager: Project 1 Assignment Buffer Manager: Project 1 Assignment Due: Feb 11, 2003 Introduction to Database Systems, UC Berkeley Computer Science 186 Spring 2003 1 Overview of Project 1 - Buffer Manager In this project you will add

More information

Symbol Table Generator (New and Improved) Jim Johnson, JKL Consulting, North Wales, PA

Symbol Table Generator (New and Improved) Jim Johnson, JKL Consulting, North Wales, PA PharmaSUG2011 - Paper AD19 Symbol Table Generator (New and Improved) Jim Johnson, JKL Consulting, North Wales, PA ABSTRACT In Seattle at the PharmaSUG 2000 meeting the Symbol Table Generator was first

More information

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Programming Standards: You must conform to good programming/documentation standards. Some specifics: CS3114 (Spring 2011) PROGRAMMING ASSIGNMENT #3 Due Thursday, April 7 @ 11:00 PM for 100 points Early bonus date: Wednesday, April 6 @ 11:00 PM for a 10 point bonus Initial Schedule due Thursday, March

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

Flow Control. CSC215 Lecture

Flow Control. CSC215 Lecture Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements

More information

PharmaSUG Paper TT11

PharmaSUG Paper TT11 PharmaSUG 2014 - Paper TT11 What is the Definition of Global On-Demand Reporting within the Pharmaceutical Industry? Eric Kammer, Novartis Pharmaceuticals Corporation, East Hanover, NJ ABSTRACT It is not

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

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

3 An NCL Tutorial Tandem Computers Incorporated 3 1

3 An NCL Tutorial Tandem Computers Incorporated 3 1 3 An NCL Tutorial Perhaps the best way to learn how to use NCL is to write a couple of NCL procedures and execute them. This section guides you through the steps required to do so. This section covers

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

8. Control statements

8. Control statements 8. Control statements A simple C++ statement is each of the individual instructions of a program, like the variable declarations and expressions seen in previous sections. They always end with a semicolon

More information

EXTRACTING DATA FOR MAILING LISTS OR REPORTS

EXTRACTING DATA FOR MAILING LISTS OR REPORTS EXTRACTING DATA FOR MAILING LISTS OR REPORTS The data stored in your files provide a valuable source of information. There are many reports in Lakeshore but sometimes you may need something unique or you

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

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

FSEDIT Procedure Windows

FSEDIT Procedure Windows 25 CHAPTER 4 FSEDIT Procedure Windows Overview 26 Viewing and Editing Observations 26 How the Control Level Affects Editing 27 Scrolling 28 Adding Observations 28 Entering and Editing Variable Values 28

More information

Perl Basics. Structure, Style, and Documentation

Perl Basics. Structure, Style, and Documentation Perl Basics Structure, Style, and Documentation Copyright 2006 2009 Stewart Weiss Easy to read programs Your job as a programmer is to create programs that are: easy to read easy to understand, easy to

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

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

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

Chapter 2 The SAS Environment

Chapter 2 The SAS Environment Chapter 2 The SAS Environment Abstract In this chapter, we begin to become familiar with the basic SAS working environment. We introduce the basic 3-screen layout, how to navigate the SAS Explorer window,

More information

LESSON 13: LANGUAGE TRANSLATION

LESSON 13: LANGUAGE TRANSLATION LESSON 13: LANGUAGE TRANSLATION Objective Interpreters and Compilers. Language Translation Phases. Interpreters and Compilers A COMPILER is a program that translates a complete source program into machine

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

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

USING DATA TO SET MACRO PARAMETERS

USING DATA TO SET MACRO PARAMETERS USING DATA TO SET MACRO PARAMETERS UPDATE A PREVIOUS EXAMPLE %macro report(regs=); %let r=1; %let region=%scan(&regs,&r); %do %until(&region eq ); options nodate pageno=1; ods pdf file="&region..pdf";

More information

variable, and executes a clist.

variable, and executes a clist. Using TSO Clists and ISPF for Generating SAS Programs INTRODUCTION Hallett German, GTE LABORATORIES Inc. TSO Clists (pronounced SEE-LISTS) and ISPFbased applications are frequently presented at SUGI. However,

More information

MLP (Multi-Link Programming) SOFTWARE

MLP (Multi-Link Programming) SOFTWARE FOR REVISIONS 1.10 AND ABOVE Doc-6001005 Rev - 3380 USER'S GUIDE TO MLP (Multi-Link Programming) SOFTWARE CHATSWORTH, CALIFORNIA Multi-Link Programming software makes programming a chain of Sentex Infinity

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

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

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

SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7

SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7 SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7 Hi everyone once again welcome to this lecture we are actually the course is Linux programming and scripting we have been talking about the Perl, Perl

More information

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to: Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both

More information

DK2. Handel-C code optimization

DK2. Handel-C code optimization DK2 Handel-C code optimization Celoxica, the Celoxica logo and Handel-C are trademarks of Celoxica Limited. All other products or services mentioned herein may be trademarks of their respective owners.

More information

Effectively Utilizing Loops and Arrays in the DATA Step

Effectively Utilizing Loops and Arrays in the DATA Step Paper 1618-2014 Effectively Utilizing Loops and Arrays in the DATA Step Arthur Li, City of Hope National Medical Center, Duarte, CA ABSTRACT The implicit loop refers to the DATA step repetitively reading

More information

Microsoft Access XP (2002) - Advanced Queries

Microsoft Access XP (2002) - Advanced Queries Microsoft Access XP (2002) - Advanced Queries Group/Summary Operations Change Join Properties Not Equal Query Parameter Queries Working with Text IIF Queries Expression Builder Backing up Tables Action

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

VERSION 7 JUNE Union Benefits. Employer User Guide Data Collection Tool

VERSION 7 JUNE Union Benefits. Employer User Guide Data Collection Tool VERSION 7 JUNE 2018 Union Benefits Employer User Guide Data Collection Tool About this guide This document is intended to provide an overview of the main sections of the Data Collection Tool ( DCT ) for

More information

Summarizing Impossibly Large SAS Data Sets For the Data Warehouse Server Using Horizontal Summarization

Summarizing Impossibly Large SAS Data Sets For the Data Warehouse Server Using Horizontal Summarization Summarizing Impossibly Large SAS Data Sets For the Data Warehouse Server Using Horizontal Summarization Michael A. Raithel, Raithel Consulting Services Abstract Data warehouse applications thrive on pre-summarized

More information

Other Loop Options EXAMPLE

Other Loop Options EXAMPLE C++ 14 By EXAMPLE Other Loop Options Now that you have mastered the looping constructs, you should learn some loop-related statements. This chapter teaches the concepts of timing loops, which enable you

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 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

Rexx Power Tools - The PARSE Command

Rexx Power Tools - The PARSE Command Rexx Power Tools - The PARSE Command Session 11751 August 7, 2012 Thomas Conley Pinnacle Consulting Group, Inc. (PCG) 59 Applewood Drive Rochester, NY 14612-3501 P: (585)720-0012 F: (585)723-3713 pinncons@rochester.rr.com

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

ADVANCED LICENSING. Advanced Licensing v Page 1 of 18

ADVANCED LICENSING. Advanced Licensing v Page 1 of 18 ADVANCED LICENSING Advanced Licensing v.20130626 Page 1 of 18 The License module is available to those PetPoint Organizations that have purchased the Constituent Services Suite. It is for selling and renewing

More information

CD Assignment I. 1. Explain the various phases of the compiler with a simple example.

CD Assignment I. 1. Explain the various phases of the compiler with a simple example. CD Assignment I 1. Explain the various phases of the compiler with a simple example. The compilation process is a sequence of various phases. Each phase takes input from the previous, and passes the output

More information

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming

More information

Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras

Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras Programming Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science Indian Institute of Technology, Madras Module 12B Lecture - 41 Brief introduction to C++ Hello, welcome

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Unit 6 - Software Design and Development LESSON 3 KEY FEATURES Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools.

More information

... ) city (city, cntyid, area, pop,.. )

... ) city (city, cntyid, area, pop,.. ) PaperP829 PROC SQl - Is it a Required Tool for Good SAS Programming? Ian Whitlock, Westat Abstract No one SAS tool can be the answer to all problems. However, it should be hard to consider a SAS programmer

More information

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

;... _... name; tsoge. scr purpose: Startup a TSO SAS session. notes: Assumes the TSO session has been logged on manually. AUTOMATING THE PROCESS OF DOWNLOADING SAS DATA SETS TO THE PC Bruce Nawrocki, GE Capital Mortgage Insurance Introduction The [nfonn.tion Center at GE Capital Mortgage Insurance supports about 50 people

More information

* Link customized PF key settings for

* Link customized PF key settings for comprehensive usage of PROC FSEDIT, version 6. Andrew P. Ford, Northern Indiana Public Service Company, Merrillville, Indiana ABSTRACT This paper presents an advanced application of FSEDIT under version

More information

CS 4201 Compilers 2014/2015 Handout: Lab 1

CS 4201 Compilers 2014/2015 Handout: Lab 1 CS 4201 Compilers 2014/2015 Handout: Lab 1 Lab Content: - What is compiler? - What is compilation? - Features of compiler - Compiler structure - Phases of compiler - Programs related to compilers - Some

More information

What Is New in CSI-Data-Miner 6.0A and B?

What Is New in CSI-Data-Miner 6.0A and B? Data-Miner 6.0A "Auto" and "Task" mode scripts Data-Miner will now run in either "Auto" mode or "Task" mode. Auto is the way that previous versions of Data-Miner have operated with reading and writing

More information

Intellicus Enterprise Reporting and BI Platform

Intellicus Enterprise Reporting and BI Platform Designing Adhoc Reports Intellicus Enterprise Reporting and BI Platform Intellicus Technologies info@intellicus.com www.intellicus.com Designing Adhoc Reports i Copyright 2012 Intellicus Technologies This

More information

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

The %let is a Macro command, which sets a macro variable to the value specified. Paper 220-26 Structuring Base SAS for Easy Maintenance Gary E. Schlegelmilch, U.S. Dept. of Commerce, Bureau of the Census, Suitland MD ABSTRACT Computer programs, by their very nature, are built to be

More information

10 C Language Tips for Hardware Engineers

10 C Language Tips for Hardware Engineers 10 C Language Tips for Hardware Engineers Jacob Beningo - March 05, 2013 On its own, the software development process has numerous hazards and obstacles that require navigation in order to successfully

More information

STAT 3304/5304 Introduction to Statistical Computing. Introduction to SAS

STAT 3304/5304 Introduction to Statistical Computing. Introduction to SAS STAT 3304/5304 Introduction to Statistical Computing Introduction to SAS What is SAS? SAS (originally an acronym for Statistical Analysis System, now it is not an acronym for anything) is a program designed

More information

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

V6 Programming Fundamentals: Part 1 Stored Procedures and Beyond David Adams & Dan Beckett. All rights reserved. Summit 97 V6 Programming Fundamentals: Part 1 Stored Procedures and Beyond by David Adams & Dan Beckett 1997 David Adams & Dan Beckett. All rights reserved. Content adapted from Programming 4th Dimension:

More information

Chapter 6: The C Preprocessor

Chapter 6: The C Preprocessor C: Chapter6 Page 1 of 5 C Tutorial.......... The C preprocessor Chapter 6: The C Preprocessor AIDS TO CLEAR PROGRAMMING The preprocessor is a program that is executed just prior to the execution of the

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

Using Custom Number Formats

Using Custom Number Formats APPENDIX B Using Custom Number Formats Although Excel provides a good variety of built-in number formats, you may find that none of these suits your needs. This appendix describes how to create custom

More information

Building Routines. Quality Routines. Quality Routines. Quality Routines. Quality Routines. Routine. What makes a quality routine

Building Routines. Quality Routines. Quality Routines. Quality Routines. Quality Routines. Routine. What makes a quality routine Building Routines Routine individual function or procedure invocable for a single purpose What makes a quality routine easier to see a low quality routine low quality routine coming up Procedure HandleStuff(

More information

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d. Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)

More information

c Microsoft, 1977, 1978, 1979

c Microsoft, 1977, 1978, 1979 c Microsoft, 1977, 1978, 1979 Microsoft FORTRAN 80 User's Manual CONTENTS SECTION 1 1.1 1.2 1.3 Compiling FORTRAN Programs 5 FORTRAN-80 Command Scanner..... 5 1.1.1 Format of Commands......... 5 1.1.2

More information

STAT:5400 Computing in Statistics. Other software packages. Microsoft Excel spreadsheet very convenient for entering data in flatfile

STAT:5400 Computing in Statistics. Other software packages. Microsoft Excel spreadsheet very convenient for entering data in flatfile STAT:5400 Computing in Statistics Other Software Packages Proc import A bit on SAS macro language Lecture 26 ov 2, 2016 Kate Cowles 374 SH, 335-0727 kate-cowles@uiowaedu Other software packages Microsoft

More information

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10

More information

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; }

for (i=1; i<=100000; i++) { x = sqrt (y); // square root function cout << x+i << endl; } Ex: The difference between Compiler and Interpreter The interpreter actually carries out the computations specified in the source program. In other words, the output of a compiler is a program, whereas

More information

IBM. TSO/E REXX User's Guide. z/os. Version 2 Release 3 SA

IBM. TSO/E REXX User's Guide. z/os. Version 2 Release 3 SA z/os IBM TSO/E REXX User's Guide Version 2 Release 3 SA32-0982-30 Note Before using this information and the product it supports, read the information in Notices on page 205. This edition applies to Version

More information

Creating If/Then/Else Routines

Creating If/Then/Else Routines 10 ch10.indd 147 Creating If/Then/Else Routines You can use If/Then/Else routines to give logic to your macros. The process of the macro proceeds in different directions depending on the results of an

More information