3 Macro Storage.

Slides:



Advertisements
Similar presentations
Copyright © 2010 SAS Institute Inc. All rights reserved. SAS ® Macros: Top Ten Questions (and Answers!) Kevin Russell –Technical Support Analyst SAS Institute.
Advertisements

Chapter 11: Creating and Using Macro Programs 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
The Web Warrior Guide to Web Design Technologies
Module 4.2 File management 1. Contents Introduction The file manager Files – the basic unit of storage The need to organise Glossary 2.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
11 Chapter 2: Framework for Developing Macro Applications 2.1 Applying Best Practices 2.2 Debugging and Troubleshooting 2.3 Generating Custom Messages.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Basic And Advanced SAS Programming
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Creating SAS® Data Sets
CSCI 130 Chapter 2. Program Components main() #include Variable Definition Function Prototype Program Statements Function Call Function Definition Comments.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
I OWA S TATE U NIVERSITY Department of Animal Science Writing Flexible Codes with the SAS Macro Facility (Chapter in the 7 Little SAS Book) Animal Science.
1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study)
Copyright © 2008, SAS Institute Inc. All rights reserved. SAS ® Macros: Top-Five Questions (and Answers!) Kim Wilson –Technical Support Analyst SAS Institute.
Managing Passwords in the SAS System Allen Malone Senior Analyst/Programmer Kaiser Permanente.
Microsoft Visual Basic 2005: Reloaded Second Edition
SAS® Explorer Use and Customization Richard A. DeVenezia.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
July 29, 2003Serguei Mokhov, 1 Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.2 Date: July 18, 2004.
chap13 Chapter 13 Programming in the Large.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.
5/30/2010 SAS Macro Language Group 6 Pradnya Nimkar, Li Lin, Linsong Zhang & Loc Tran.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
Using Macros in Minitab
Module 8 : Configuration II Jong S. Bok
1 How to Quickly Customize your PC SAS Session PhilaSUG GSK October 27, 2004 Mary Anne Rutkowski Kathy Harkins Senior Statistical Programming Analysts.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
THE C PROGRAMMING ENVIRONMENT. Four parts of C environment  Main menu  Editor status line and edit window  Compiler message window  “Hot Keys” quick.
Amir Afzal UNIX Unbounded, 5th Edition Copyright ©2008 Chapter 6: The vi Editor – Last Look 1 of 55 Copyright ©2008 by Pearson Education, Inc. Upper Saddle.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Excel Tutorial 8 Developing an Excel Application
Chapter 10: Accessing Relational Databases (Self-Study)
Chapter 2: The Visual Studio .NET Development Environment
Temporary vs. Permanent SAS Data Sets
INF230 Basics in C# Programming
Jonathan W. Duggins; James Blum NC State University; UNC Wilmington
Chapter 2: Getting Data into SAS
Introduction to Programming the WWW I
Introduction to Operating System (OS)
SECTION 3 MACROS: OVERVIEW.
Some ways to encourage quality programming
Chapter 1: Introduction to SAS
Instructor: Raul Cruz-Cano
Conditional Processing
Tamara Arenovich Tony Panzarella
Fall 2017 Questions and Answers (Q&A)
Social Media And Global Computing Introduction to Visual Studio
3 Macro Parameters.
Packages and Interfaces
Macro Variable’s scope
Defining and Calling a Macro
Constructors and Other Tools
Chapter 4 File Basics.
AUTOCALL MACROS- A QUICK OVERVIEW
Dictionary Tables and Views, obtain information about SAS files
Writing Large Programs
3 Views.
Scripts In Matlab.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Stata Basic Course.
Instructor: Raul Cruz 9/4/13
SPL – PS1 Introduction to C++.
Presentation transcript:

3 Macro Storage

Two ways to store macros for re-use. Use stored compiled macros to make macros available to a SAS program. Use the autocall facility to make macros available to a SAS program. Stored compiled macros and the autocall facility are essentially two ways of doing the same thing. Both techniques allow us to store macros and make them conveniently and permanently available to any SAS session without the need to manually submit a macro definition before we can call the macro. Each technique has its own advantages and features, which are summarized at the end of this section.

Review: Produce a list of session-compiled macros stored in the default temporary catalog, work.sasmacr. proc catalog cat=work.sasmacr; contents; title "My Temporary Macros"; quit; title;

Stored Compiled Macros The MSTORED system option enables storage of compiled macros in a permanent library. The SASMSTORE= system option designates a permanent library to store compiled macros. libref points to an allocated SAS data library. OPTIONS MSTORED SASMSTORE=libref ;

Stored Compiled Macros macro definition for permanent stored compiled macros: The STORE option stores the compiled macro in the library indicated by the SASMSTORE= system option. %MACRO macro-name / STORE; macro-text %MEND macro-name;

Stored Compiled Macros Example: Store the CALC macro in a permanent library. options mstored sasmstore=tmp; %macro calc / store; proc means data=orion.order_fact &stats; var &vars; run; %mend calc;

Call the CALC macro in a new SAS session. options mstored sasmstore=tmp; %let stats=min max; %let vars=quantity; %calc

The Autocall Facility

The Autocall Facility SAS software includes an autocall library of utility macros. This makes for a good live demo outside SAS using Windows Explorer.

The Autocall Facility An autocall library is a collection of external files that contain macro definition source code. You can make macros accessible to your SAS session or job by concatenating your own autocall library or your organization's autocall library (or both) with the autocall library supplied with SAS software.

Defining an Autocall Library To define an autocall library: Specify the MAUTOSOURCE SAS system option. Use the SASAUTOS= SAS system option to identify autocall library locations.

Autocall Facility System Options The MAUTOSOURCE option controls autocall facility availability. General form of the MAUTOSOURCE|NOMAUTOSOURCE option: The default setting is MAUTOSOURCE. OPTIONS MAUTOSOURCE; OPTIONS NOMAUTOSOURCE;

Autocall Facility System Options The SASAUTOS= system option specifies the location of autocall macros. General form of the SASAUTOS= system option: OPTIONS SASAUTOS=(library-1,...,library-n); The values of library-1 through library-n are references to source libraries containing macro definitions. You specify a source library by doing one of the following: Placing its name in quotation marks Pointing to it with a fileref

Autocall Facility System Options Concatenate the autocall library supplied by SAS with your personal autocall library and/or your organization's autocall library. Windows: options mautosource sasautos=('c:\tmp',sasautos); UNIX: options mautosource sasautos=('/workshop','!SASROOT/sasautos'); z/OS: options mautosource sasautos=('my.macros',sasautos); The reserved fileref SASAUTOS is assigned to the autocall library supplied by SAS.

The Autocall Facility in Windows or UNIX In a Windows or UNIX environment, save each macro definition as a separate file within the directory specified in the SASAUTOS= option. Ensure that: Filenames have a .sas extension. The filename and the macro name match. UNIX filenames are lowercase.

Accessing Autocall Macros With the autocall facility in effect, you can call any macro in the autocall library. If you call a macro that was not previously compiled, the macro facility: Searches the autocall library for a member with the same name as the called macro Issues an error message if the member is not found Executes the macro source statements to compile the macro if the member is found Calls the macro

Accessing Autocall Macros Is a compiled macro available? Yes Execute the compiled macro No Does the macro exist in an autocall library? No WARNING: Apparent invocation of macro not resolved Yes Execute the source statements to compile the macro Execute the compiled macro

The Autocall Facility Example: Save the CALC macro in an autocall library as calc.sas. Step 1: Step 2: Step 3: options mautosource sasautos=('c:\tmp',sasautos); %macro calc; proc means data=orion.order_item &stats; var &vars; run; %mend calc; continued...

The Autocall Facility Step 4: Call the CALC macro in a new SAS session. options mautosource sasautos=('c:\tmp',sasautos); %let stats=min max; %let vars=quantity; %calc

Macro Storage Advice Advantages of stored compiled macros: You avoid re-compiling lengthy macro source code. Macro source code can be protected or hidden. Advantages of autocall macros: They are available cross-platform. Macro source code can be edited in any text editor without invoking SAS. If none of the above considerations apply, use whichever technique is preferred in your organization or whichever technique you prefer.