SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
SAS® Macro Design
                 g
      Patterns
          Mark Tabladillo Ph D
                          Ph.D.
Software Developer, MarkTab Consulting
 Associate Faculty, University of Phoenix
              Atlanta, GA
                      ,
Introduction

Experienced SAS programmers use
macros regularly
The Macro Facility has two components
  The macro processor (engine or mechanism)
  The macro language (syntax)
Power of SAS Macros

Power Source       Definition                               Examples
Function           The SAS System has added specific        •   %LENGTH
                       macro functions.                     •   %EVAL
                                                            •   %SYSFUNC
                                                            See SAS Institute (2005)
Implementation     The SAS System defines specific ways     •   Global versus local macro
                       that macro variables and macros          variables
                       resolve.                             •   %DO inside macros
                                                            See SAS Institute (2005)
Structure          The SAS Macro language has some          To some extent:
                       characteristics of object-oriented
                                          object-           •   Encapsulation
                       languages.                           •   Polymorphism
                                                            •   Inheritance
                                                            See Tabladillo (2005)
SAS Macro Design Patterns

 Focus:
 Focus: structural power
 Approach:
 A         h
 Approach: provide examples on how
                   id        l    h
 macros can implement some aspects of
 object- i
 object-oriented d i patterns
  bj            d design
 Mission:
 Mission: to provide specific design ideas
 for structuring macros in the most
 powerful way possible
Outline
First:
First: Illustrate three specific ways to trick the
SAS macro language to emulate some
properties of object-oriented languages.
               object-
Second:
Second: Answer what a design pattern is and why
design patterns are useful.
Third: List seven specific design patterns and
provide SAS macro language examples.
Finally: Provide some general application
advice.
Overview

How to trick the SAS Macro
Language
Why design patterns are useful
Six specific design patterns
General application development advice
          pp                p
How to Trick the SAS Macro
        Language

 Trick One – emulate inheritance by
 cutting and pasting text
 There is no %INHERIT
How to Trick the SAS Macro
        Language

 Trick Two – emulate all types of variables
 with macro variables
 Macro variables are inherently character
How to Trick the SAS Macro
        Language
%macro interface(char, num, array, macro);
                (     ,   ,     y,      );
%local major;
%macro breakarray(m, n, p, q);
data _null_;
         call symput('major',&m);
         run;
%put &m &n &p &q;
%mend breakarray;
%macro submacro(a, b);
%put &a &b;
%mend submacro;
%put &char &num &array &macro;
* Break up the array;
%breakarray&array.;
%put &major;
* Call the named macro;
%&macro.;
%mend interface;
%interface (char=character, num=2005, array=(1,2,3,4),
macro=submacro(a=5,b=c));
How to Trick the SAS Macro
        Language

 Trick Three – emulate public functions
 (or methods) by applying nested macros
 Macros do not expose internal functions
 However, developers can write nested
 macros
Overview

How to trick the SAS Macro Language
Wh d i patterns are useful
Why design                   f l
Six specific design patterns
General application development advice
Design Pattern Fundamentals

  Pattern – a solution to a problem in
  context
  Patterns provide a way to solve
  commonly recurring problems with two
           l        i       bl     ih
  goals:
    Reuse Solutions
    Establish Common Terminology
Overview

How to trick the SAS Macro Language
Wh d i patterns are useful
Why design                 f l
Six specific design patterns
General application development advice
FACADE: SIMPLIFY A
      COMPLEX SYSTEM
               Façade Pattern Key Features
Intent         You want to simplify how to use an existing system. You need to
                  define your own interface
                                    interface.
Problem        You need to use only a subset of a complex system. Or you need to
                  interact with the system in a particular way.
Solution       The Facade presents a new interface for the client of the existing
                   system to use.
Consequences   The Façade simplifies the use of the required subsystem. However,
                   since the Façade is not complete, certain functionality may be
                   unavailable to the client.
                         il bl     h li
FACADE: SIMPLIFY A
    COMPLEX SYSTEM
FULLY IMPLEMENTED EXAMPLE
%macro facade(dataset);
proc freq data=&dataset.;
       tables year*sales/list missing;
       run;
proc means data=&dataset.;
       var annualSales totalEmployees sumTurnover;
       run;
%mend facade;
%facade(dataset=sales.ca200503);
%facade(dataset=sales.ca200510);
%facade(dataset=sales.ca200511);
%facade(dataset=sales ca200511);
STRATEGY: USE DIFFERENT BUSINESS
    RULES DEPENDING ON CONTEXT

               Strategy Pattern Key Features

Intent         Allows you to use different business rules or algorithms depending on the
                   context in which they occur.

Problem        The selection of an algorithm that needs to be applied depends upon the
                   client making the request or the data being acted upon. If you simply
                   have a rule in place that does not change, you do not need a Strategy
                   pattern.
Solution       Separates the selection of the algorithm from the implementation of the
                   algorithm. Allows for the selection to be made based upon context.

Consequences   •   The Strategy pattern defines a family of algorithms.
               •   Switches and/or conditionals can be eliminated.
               •   You must invoke all algorithms in the same way (they must all have the
                   same interface).
                        interface)
STRATEGY: USE DIFFERENT BUSINESS
    RULES DEPENDING ON CONTEXT
FULLY IMPLEMENTED EXAMPLE
data work.taxExample;
          length grossAmount totalTax 8;
          grossAmount = 34000;
          run;
%macro calculateTaxes(dataset,county);
%macro taxStrategy(county);
%                  (      )
%macro DeKalb;
          totalTax = grossAmount * 0.06;
%mend deKalb;
%macro Fulton;
          totalTax = grossAmount * 0 075;
                                   0.075;
%mend Fulton;
%macro Gwinnett;
          totalTax = grossAmount * 0.06;
%mend Gwinnett;
%if &county. = DeKalb or &county. = Fulton or &county. = Gwinnett %then %&county.;
%mend taxStrategy;
data &dataset.;
          set &dataset.;
          %taxStrategy(&county.);
          run;
proc print d t
       i t data=&dataset.;
                 d t   t
          run;
%mend calculateTaxes;
%calculateTaxes(dataset=work.taxExample, county=Fulton);
SINGLETON: HAVE ONLY
ONE OBJECT AVAILABLE

               Decorator Pattern Key Features
Intent         You want to have only one of an object but there is no global object
                  that controls the instantiation of the object.
Problem        Several different client objects need to refer to the same thing and
                   you want to ensure that you do not have more than one of them.

Solution       Guarantees one instance.
Consequences   Clients need not concern themselves whether an instance of the
                   singleton object exists.
                      g         j
SINGLETON: HAVE ONLY ONE
     OBJECT AVAIABLE

  Fully Implemented Singleton Pattern:
  Only one SAS Macro is allowed
  Only one SAS local named variable
  Only one SAS global named variable
  Only one instance of a base SAS session
     y
DECORATOR: ATTACH ADDITIONAL
 RESPONSIBILITIES DYNAMICALLY


                Decorator Pattern Key Features
 Intent         Attach additional responsibilities to an object dynamically.
 Problem        The object that you want to use does the basic functions you require.
                    However, you may need to add some additional functionality to
                    the object occurring before or after the object’s base
                    functionality.
                                y
 Solution       Allows for extending the functionality of an object without resorting
                    to subclassing.
 Consequences   Functionality that is to be added resides in small objects. The
                   advantage is the ability to dynamically add this function before or
                   after the core functionality.
DECORATOR: ATTACH ADDITIONAL
 RESPONSIBILITIES DYNAMICALLY
  PARTIALLY IMPLEMENTED DECORATOR PATTERN
  %macro messyMacro(num,char);
            * Messy Macro;
            %put MessyMacro &num. &char.;
  %mend messyMacro;

  %macro decoratorBefore(parameters);
            %put Before;
            %messyMacro&parameters.;
  %mend decoratorBefore;

  %
  %macro d     t B f
         decoratorBeforeAndAfter(parameters);
                         A dAft (      t   )
            %put Before;
            %messyMacro&parameters.;
            %put After;
  %mend decoratorBeforeAndAfter;

  %macro decoratorAfter(parameters);
            %messyMacro&parameters.;
            %put After;
  %mend decoratorAfter;

  %decoratorBeforeAndAfter(parameters=(num=1,char=SAS));
TEMPLATE METHOD: APPLY DISCIPLINE TO
THE FUNCTIONS AVAILABLE INSIDE MACROS


                  Template Method Pattern Key Features
   Intent         Define the skeleton of an algorithm in an operation, deferring
                      some steps to subclasses. Redefine the steps in an algorithm
                      without changing the algorithm’s structure
   Problem        There is a procedure or set of steps to follow that is consistent
                     at one level of detail, but individual steps may have different
                     implementations at a lower level of detail.
   Solution       Allows for definition of substeps that vary while maintaining a
                      consistent basic process.
   Consequences   Templates provide a good platform for code reuse. They are
                     also helpful in ensuring the required steps are implemented.
TEMPLATE METHOD: APPLY DISCIPLINE TO
       THE FUNCTIONS AVAILABLE INSIDE MACROS

%macro accessSAS(connectParameters,selectRecordParameters);   %macro accessSQLServer(connectParameters,selectRecordParameters);
%macro connectDB(num,char);                                   %macro connectDB(num,char);
%put SAS ConnectDB;                                           %put SQL Server ConnectDB;
%mend connectDB;                                              %mend connectDB;
%macro selectRecords(num,char);                               %macro selectRecords(num,char);
%put SAS Record Selection;                                    %put SQL Server Record Selection;
%mend selectRecords;                                          %mend selectRecords;
%macro doQuery;                                               %macro doQuery;
* doQuery is the same for all macros;                         * doQuery is the same for all macros;
%connectDB&connectparameters.;                                %connectDB&connectparameters.;
%selectRecords&selectRecordParameters.;                       %selectRecords&selectRecordParameters.;
%mend doQuery;                                                %mend doQuery;
%doQuery;                                                     %doQuery;
%mend accessSAS;                                              %mend accessSQLServer;



    PARTIALLY IMPLEMENTED TEMPLATE METHOD:
           Two different macros, same nested macros

    %accessSAS(connectParameters=(num=1,char=SAS),
    selectRecordParameters=(num=2,char=SAS));
    %accessSQLServer(connectParameters=(num=1,char=SQLServer),
    selectRecordParameters=(num=2,char=SQLServer));
ANALYSIS MATRIX: HIGH-
                  HIGH-
VOLUME MACRO PROCESSING

                Analysis Matrix Method Pattern Key Features
 Intent         Provide a systematic way to surface varying dimensions of change.

 Problem        Variations in the system need to be made explicit so that applying
                    design patterns becomes easier.
 Solution       Create a matrix which documents the concepts which are varying.
                                                           p                y g
                    Matrix creation can help the developer discover the concepts that
                    are varying, find points of commonality, and uncover missing
                    requirements.
 Consequences   The final design is optimized for the surfaced dimensions, and
                                                               dimensions
                    refactoring may be required if dimensions are added or removed.
ANALYSIS MATRIX: HIGH-
                  HIGH-
VOLUME MACRO PROCESSING

                     U.S. Sales        Canadian Sales    German Sales


 Calculate freight    Combination       Combination        Combination
 Verify address       Combination       Combination        Combination
 Calculate tax        Combination       Combination        Combination
 Money                Combination       Combination        Combination
 Dates                Combination       Combination        Combination
 Maximum              Combination       Combination        Combination
    weight
     Analysis Matrix Example (Shalloway and Trott, 2005, p. 286)
Overview

How to trick the SAS Macro Language
Why design
Wh d i patterns are useful   f l
Six specific design patterns
General application development
advice
General Application Advice

The
Th examples ill
          l illustrate conceptual design
                                 ld i
patterns
The examples could be used as is, or
combined with one another
Consider upgrading to SAS/AF
Most optionally licensed products represent
procedures which extend base SAS
Conclusion
This presentation:
     p
  Provided tricks for object-oriented emulation
                      object-
  Defined and defended design patterns
  Demonstrated fully or partially implemented
  design patterns
  Provided application advice
Read more (books or web) on design patterns
to deepen your topical understanding
References
Fowler, Martin (1999), Refactoring: Improving the Design of Existing
Code,
Code, Reading, MA: Addison Wesley Longman, Inc.
Gamma, E., Helm, R., Johnson, R., Vlissides, J. (1995), Design
Patterns: Elements of Reusable Object-Oriented Software, Reading MA:
                               Object-         Software, Reading,
Addison Wesley Longman, Inc.
SAS Institute Inc. (2005), SAS OnlineDoc® 9.1.3, Cary, NC: SAS
                                                9.1.3,
Institute, Inc.
Shalloway, A., and Trott, J. (2005), Design Patterns Explained: a New
Perspective on Object-Oriented Design (Second Edition), Boston MA:
               Object-                        Edition), Boston,
Addison-
Addison-Wesley, Inc.
Tabladillo, M. (2005), “Macro Architecture in Pictures”, SUGI
                 (
Proceedings,
Proceedings, 2005.
Contact Information

            Mark Tabladillo
Software Developer, MarkTab C
S f      D l        M kT b Consulting
                                li
       http://www.marktab.com

Weitere ähnliche Inhalte

Was ist angesagt?

SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3venkatam
 
Reading Fixed And Varying Data
Reading Fixed And Varying DataReading Fixed And Varying Data
Reading Fixed And Varying Dataguest2160992
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sashalasti
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processingguest2160992
 
Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Mark Tabladillo
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Proceduresguest2160992
 
Improving Effeciency with Options in SAS
Improving Effeciency with Options in SASImproving Effeciency with Options in SAS
Improving Effeciency with Options in SASguest2160992
 
SAS cheat sheet
SAS cheat sheetSAS cheat sheet
SAS cheat sheetAli Ajouz
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SASguest2160992
 
Base SAS Full Sample Paper
Base SAS Full Sample Paper Base SAS Full Sample Paper
Base SAS Full Sample Paper Jimmy Rana
 
SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connectguest2160992
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.Ravi Mandal, MBA
 
Learn SAS Programming
Learn SAS ProgrammingLearn SAS Programming
Learn SAS ProgrammingSASTechies
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set OptionsMark Tabladillo
 
SAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSrinimf-Slides
 

Was ist angesagt? (20)

SAS Functions
SAS FunctionsSAS Functions
SAS Functions
 
SAS Macros part 3
SAS Macros part 3SAS Macros part 3
SAS Macros part 3
 
Reading Fixed And Varying Data
Reading Fixed And Varying DataReading Fixed And Varying Data
Reading Fixed And Varying Data
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
 
Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processing
 
Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Procedures
 
Improving Effeciency with Options in SAS
Improving Effeciency with Options in SASImproving Effeciency with Options in SAS
Improving Effeciency with Options in SAS
 
SAS cheat sheet
SAS cheat sheetSAS cheat sheet
SAS cheat sheet
 
SAS Macro
SAS MacroSAS Macro
SAS Macro
 
SAS ODS HTML
SAS ODS HTMLSAS ODS HTML
SAS ODS HTML
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SAS
 
Base SAS Full Sample Paper
Base SAS Full Sample Paper Base SAS Full Sample Paper
Base SAS Full Sample Paper
 
SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connect
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.
 
Learn SAS Programming
Learn SAS ProgrammingLearn SAS Programming
Learn SAS Programming
 
Sas Plots Graphs
Sas Plots GraphsSas Plots Graphs
Sas Plots Graphs
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set Options
 
SAS Mainframe -Program-Tips
SAS Mainframe -Program-TipsSAS Mainframe -Program-Tips
SAS Mainframe -Program-Tips
 
Proc sql tips
Proc sql tipsProc sql tips
Proc sql tips
 

Ähnlich wie Sas® Macro Design Patterns

Java script tutorial by example
Java script tutorial by exampleJava script tutorial by example
Java script tutorial by examplemyzyzy
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsimedo.de
 
ALMOsT.js: an Agile Model to Model and Model to Text Transformation Framework
ALMOsT.js: an Agile Model to Model and Model to Text Transformation FrameworkALMOsT.js: an Agile Model to Model and Model to Text Transformation Framework
ALMOsT.js: an Agile Model to Model and Model to Text Transformation FrameworkCarlo Bernaschina
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011David O'Dowd
 
Flex 4.5 jeyasekar
Flex 4.5  jeyasekarFlex 4.5  jeyasekar
Flex 4.5 jeyasekarjeya soft
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
04b swing tutorial
04b swing tutorial04b swing tutorial
04b swing tutorialRobert Wolf
 
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...Solution de génération de rapport OpenDocument à partir de plusieurs sources ...
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...EclipseDayParis
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldSaurabh Moody
 
Evaluation of meta modeling tools for domain specific modeling language chnjl
Evaluation of meta modeling   tools for domain specific modeling language chnjlEvaluation of meta modeling   tools for domain specific modeling language chnjl
Evaluation of meta modeling tools for domain specific modeling language chnjlPG Scholar
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? reactima
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsMike Wilcox
 

Ähnlich wie Sas® Macro Design Patterns (20)

p032-26
p032-26p032-26
p032-26
 
p032-26
p032-26p032-26
p032-26
 
Java script tutorial by example
Java script tutorial by exampleJava script tutorial by example
Java script tutorial by example
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
MVC
MVCMVC
MVC
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
ALMOsT.js: an Agile Model to Model and Model to Text Transformation Framework
ALMOsT.js: an Agile Model to Model and Model to Text Transformation FrameworkALMOsT.js: an Agile Model to Model and Model to Text Transformation Framework
ALMOsT.js: an Agile Model to Model and Model to Text Transformation Framework
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011
 
Flex 4.5 jeyasekar
Flex 4.5  jeyasekarFlex 4.5  jeyasekar
Flex 4.5 jeyasekar
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
 
04b swing tutorial
04b swing tutorial04b swing tutorial
04b swing tutorial
 
04b swing tutorial
04b swing tutorial04b swing tutorial
04b swing tutorial
 
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...Solution de génération de rapport OpenDocument à partir de plusieurs sources ...
Solution de génération de rapport OpenDocument à partir de plusieurs sources ...
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Evaluation of meta modeling tools for domain specific modeling language chnjl
Evaluation of meta modeling   tools for domain specific modeling language chnjlEvaluation of meta modeling   tools for domain specific modeling language chnjl
Evaluation of meta modeling tools for domain specific modeling language chnjl
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
JavaFX in Action Part I
JavaFX in Action Part IJavaFX in Action Part I
JavaFX in Action Part I
 

Mehr von Mark Tabladillo

How to find low-cost or free data science resources 202006
How to find low-cost or free data science resources 202006How to find low-cost or free data science resources 202006
How to find low-cost or free data science resources 202006Mark Tabladillo
 
Microsoft Build 2020: Data Science Recap
Microsoft Build 2020: Data Science RecapMicrosoft Build 2020: Data Science Recap
Microsoft Build 2020: Data Science RecapMark Tabladillo
 
201909 Automated ML for Developers
201909 Automated ML for Developers201909 Automated ML for Developers
201909 Automated ML for DevelopersMark Tabladillo
 
201908 Overview of Automated ML
201908 Overview of Automated ML201908 Overview of Automated ML
201908 Overview of Automated MLMark Tabladillo
 
201906 01 Introduction to ML.NET 1.0
201906 01 Introduction to ML.NET 1.0201906 01 Introduction to ML.NET 1.0
201906 01 Introduction to ML.NET 1.0Mark Tabladillo
 
201906 04 Overview of Automated ML June 2019
201906 04 Overview of Automated ML June 2019201906 04 Overview of Automated ML June 2019
201906 04 Overview of Automated ML June 2019Mark Tabladillo
 
201906 03 Introduction to NimbusML
201906 03 Introduction to NimbusML201906 03 Introduction to NimbusML
201906 03 Introduction to NimbusMLMark Tabladillo
 
201906 02 Introduction to AutoML with ML.NET 1.0
201906 02 Introduction to AutoML with ML.NET 1.0201906 02 Introduction to AutoML with ML.NET 1.0
201906 02 Introduction to AutoML with ML.NET 1.0Mark Tabladillo
 
201905 Azure Databricks for Machine Learning
201905 Azure Databricks for Machine Learning201905 Azure Databricks for Machine Learning
201905 Azure Databricks for Machine LearningMark Tabladillo
 
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...201905 Azure Certification DP-100: Designing and Implementing a Data Science ...
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...Mark Tabladillo
 
Big Data Advanced Analytics on Microsoft Azure 201904
Big Data Advanced Analytics on Microsoft Azure 201904Big Data Advanced Analytics on Microsoft Azure 201904
Big Data Advanced Analytics on Microsoft Azure 201904Mark Tabladillo
 
Managing Enterprise Data Science 201904
Managing Enterprise Data Science 201904Managing Enterprise Data Science 201904
Managing Enterprise Data Science 201904Mark Tabladillo
 
Training of Python scikit-learn models on Azure
Training of Python scikit-learn models on AzureTraining of Python scikit-learn models on Azure
Training of Python scikit-learn models on AzureMark Tabladillo
 
Big Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureBig Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureMark Tabladillo
 
Advanced Analytics with Power BI 201808
Advanced Analytics with Power BI 201808Advanced Analytics with Power BI 201808
Advanced Analytics with Power BI 201808Mark Tabladillo
 
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)Mark Tabladillo
 
Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017Mark Tabladillo
 
Microsoft Technologies for Data Science 201612
Microsoft Technologies for Data Science 201612Microsoft Technologies for Data Science 201612
Microsoft Technologies for Data Science 201612Mark Tabladillo
 
How Big Companies plan to use Our Big Data 201610
How Big Companies plan to use Our Big Data 201610How Big Companies plan to use Our Big Data 201610
How Big Companies plan to use Our Big Data 201610Mark Tabladillo
 
Georgia Tech Data Science Hackathon September 2016
Georgia Tech Data Science Hackathon September 2016Georgia Tech Data Science Hackathon September 2016
Georgia Tech Data Science Hackathon September 2016Mark Tabladillo
 

Mehr von Mark Tabladillo (20)

How to find low-cost or free data science resources 202006
How to find low-cost or free data science resources 202006How to find low-cost or free data science resources 202006
How to find low-cost or free data science resources 202006
 
Microsoft Build 2020: Data Science Recap
Microsoft Build 2020: Data Science RecapMicrosoft Build 2020: Data Science Recap
Microsoft Build 2020: Data Science Recap
 
201909 Automated ML for Developers
201909 Automated ML for Developers201909 Automated ML for Developers
201909 Automated ML for Developers
 
201908 Overview of Automated ML
201908 Overview of Automated ML201908 Overview of Automated ML
201908 Overview of Automated ML
 
201906 01 Introduction to ML.NET 1.0
201906 01 Introduction to ML.NET 1.0201906 01 Introduction to ML.NET 1.0
201906 01 Introduction to ML.NET 1.0
 
201906 04 Overview of Automated ML June 2019
201906 04 Overview of Automated ML June 2019201906 04 Overview of Automated ML June 2019
201906 04 Overview of Automated ML June 2019
 
201906 03 Introduction to NimbusML
201906 03 Introduction to NimbusML201906 03 Introduction to NimbusML
201906 03 Introduction to NimbusML
 
201906 02 Introduction to AutoML with ML.NET 1.0
201906 02 Introduction to AutoML with ML.NET 1.0201906 02 Introduction to AutoML with ML.NET 1.0
201906 02 Introduction to AutoML with ML.NET 1.0
 
201905 Azure Databricks for Machine Learning
201905 Azure Databricks for Machine Learning201905 Azure Databricks for Machine Learning
201905 Azure Databricks for Machine Learning
 
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...201905 Azure Certification DP-100: Designing and Implementing a Data Science ...
201905 Azure Certification DP-100: Designing and Implementing a Data Science ...
 
Big Data Advanced Analytics on Microsoft Azure 201904
Big Data Advanced Analytics on Microsoft Azure 201904Big Data Advanced Analytics on Microsoft Azure 201904
Big Data Advanced Analytics on Microsoft Azure 201904
 
Managing Enterprise Data Science 201904
Managing Enterprise Data Science 201904Managing Enterprise Data Science 201904
Managing Enterprise Data Science 201904
 
Training of Python scikit-learn models on Azure
Training of Python scikit-learn models on AzureTraining of Python scikit-learn models on Azure
Training of Python scikit-learn models on Azure
 
Big Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft AzureBig Data Adavnced Analytics on Microsoft Azure
Big Data Adavnced Analytics on Microsoft Azure
 
Advanced Analytics with Power BI 201808
Advanced Analytics with Power BI 201808Advanced Analytics with Power BI 201808
Advanced Analytics with Power BI 201808
 
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)
Microsoft Cognitive Toolkit (Atlanta Code Camp 2017)
 
Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017
 
Microsoft Technologies for Data Science 201612
Microsoft Technologies for Data Science 201612Microsoft Technologies for Data Science 201612
Microsoft Technologies for Data Science 201612
 
How Big Companies plan to use Our Big Data 201610
How Big Companies plan to use Our Big Data 201610How Big Companies plan to use Our Big Data 201610
How Big Companies plan to use Our Big Data 201610
 
Georgia Tech Data Science Hackathon September 2016
Georgia Tech Data Science Hackathon September 2016Georgia Tech Data Science Hackathon September 2016
Georgia Tech Data Science Hackathon September 2016
 

Kürzlich hochgeladen

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Kürzlich hochgeladen (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Sas® Macro Design Patterns

  • 1. SAS® Macro Design g Patterns Mark Tabladillo Ph D Ph.D. Software Developer, MarkTab Consulting Associate Faculty, University of Phoenix Atlanta, GA ,
  • 2. Introduction Experienced SAS programmers use macros regularly The Macro Facility has two components The macro processor (engine or mechanism) The macro language (syntax)
  • 3. Power of SAS Macros Power Source Definition Examples Function The SAS System has added specific • %LENGTH macro functions. • %EVAL • %SYSFUNC See SAS Institute (2005) Implementation The SAS System defines specific ways • Global versus local macro that macro variables and macros variables resolve. • %DO inside macros See SAS Institute (2005) Structure The SAS Macro language has some To some extent: characteristics of object-oriented object- • Encapsulation languages. • Polymorphism • Inheritance See Tabladillo (2005)
  • 4. SAS Macro Design Patterns Focus: Focus: structural power Approach: A h Approach: provide examples on how id l h macros can implement some aspects of object- i object-oriented d i patterns bj d design Mission: Mission: to provide specific design ideas for structuring macros in the most powerful way possible
  • 5. Outline First: First: Illustrate three specific ways to trick the SAS macro language to emulate some properties of object-oriented languages. object- Second: Second: Answer what a design pattern is and why design patterns are useful. Third: List seven specific design patterns and provide SAS macro language examples. Finally: Provide some general application advice.
  • 6. Overview How to trick the SAS Macro Language Why design patterns are useful Six specific design patterns General application development advice pp p
  • 7. How to Trick the SAS Macro Language Trick One – emulate inheritance by cutting and pasting text There is no %INHERIT
  • 8. How to Trick the SAS Macro Language Trick Two – emulate all types of variables with macro variables Macro variables are inherently character
  • 9. How to Trick the SAS Macro Language %macro interface(char, num, array, macro); ( , , y, ); %local major; %macro breakarray(m, n, p, q); data _null_; call symput('major',&m); run; %put &m &n &p &q; %mend breakarray; %macro submacro(a, b); %put &a &b; %mend submacro; %put &char &num &array &macro; * Break up the array; %breakarray&array.; %put &major; * Call the named macro; %&macro.; %mend interface; %interface (char=character, num=2005, array=(1,2,3,4), macro=submacro(a=5,b=c));
  • 10. How to Trick the SAS Macro Language Trick Three – emulate public functions (or methods) by applying nested macros Macros do not expose internal functions However, developers can write nested macros
  • 11. Overview How to trick the SAS Macro Language Wh d i patterns are useful Why design f l Six specific design patterns General application development advice
  • 12. Design Pattern Fundamentals Pattern – a solution to a problem in context Patterns provide a way to solve commonly recurring problems with two l i bl ih goals: Reuse Solutions Establish Common Terminology
  • 13. Overview How to trick the SAS Macro Language Wh d i patterns are useful Why design f l Six specific design patterns General application development advice
  • 14. FACADE: SIMPLIFY A COMPLEX SYSTEM Façade Pattern Key Features Intent You want to simplify how to use an existing system. You need to define your own interface interface. Problem You need to use only a subset of a complex system. Or you need to interact with the system in a particular way. Solution The Facade presents a new interface for the client of the existing system to use. Consequences The Façade simplifies the use of the required subsystem. However, since the Façade is not complete, certain functionality may be unavailable to the client. il bl h li
  • 15. FACADE: SIMPLIFY A COMPLEX SYSTEM FULLY IMPLEMENTED EXAMPLE %macro facade(dataset); proc freq data=&dataset.; tables year*sales/list missing; run; proc means data=&dataset.; var annualSales totalEmployees sumTurnover; run; %mend facade; %facade(dataset=sales.ca200503); %facade(dataset=sales.ca200510); %facade(dataset=sales.ca200511); %facade(dataset=sales ca200511);
  • 16. STRATEGY: USE DIFFERENT BUSINESS RULES DEPENDING ON CONTEXT Strategy Pattern Key Features Intent Allows you to use different business rules or algorithms depending on the context in which they occur. Problem The selection of an algorithm that needs to be applied depends upon the client making the request or the data being acted upon. If you simply have a rule in place that does not change, you do not need a Strategy pattern. Solution Separates the selection of the algorithm from the implementation of the algorithm. Allows for the selection to be made based upon context. Consequences • The Strategy pattern defines a family of algorithms. • Switches and/or conditionals can be eliminated. • You must invoke all algorithms in the same way (they must all have the same interface). interface)
  • 17. STRATEGY: USE DIFFERENT BUSINESS RULES DEPENDING ON CONTEXT FULLY IMPLEMENTED EXAMPLE data work.taxExample; length grossAmount totalTax 8; grossAmount = 34000; run; %macro calculateTaxes(dataset,county); %macro taxStrategy(county); % ( ) %macro DeKalb; totalTax = grossAmount * 0.06; %mend deKalb; %macro Fulton; totalTax = grossAmount * 0 075; 0.075; %mend Fulton; %macro Gwinnett; totalTax = grossAmount * 0.06; %mend Gwinnett; %if &county. = DeKalb or &county. = Fulton or &county. = Gwinnett %then %&county.; %mend taxStrategy; data &dataset.; set &dataset.; %taxStrategy(&county.); run; proc print d t i t data=&dataset.; d t t run; %mend calculateTaxes; %calculateTaxes(dataset=work.taxExample, county=Fulton);
  • 18. SINGLETON: HAVE ONLY ONE OBJECT AVAILABLE Decorator Pattern Key Features Intent You want to have only one of an object but there is no global object that controls the instantiation of the object. Problem Several different client objects need to refer to the same thing and you want to ensure that you do not have more than one of them. Solution Guarantees one instance. Consequences Clients need not concern themselves whether an instance of the singleton object exists. g j
  • 19. SINGLETON: HAVE ONLY ONE OBJECT AVAIABLE Fully Implemented Singleton Pattern: Only one SAS Macro is allowed Only one SAS local named variable Only one SAS global named variable Only one instance of a base SAS session y
  • 20. DECORATOR: ATTACH ADDITIONAL RESPONSIBILITIES DYNAMICALLY Decorator Pattern Key Features Intent Attach additional responsibilities to an object dynamically. Problem The object that you want to use does the basic functions you require. However, you may need to add some additional functionality to the object occurring before or after the object’s base functionality. y Solution Allows for extending the functionality of an object without resorting to subclassing. Consequences Functionality that is to be added resides in small objects. The advantage is the ability to dynamically add this function before or after the core functionality.
  • 21. DECORATOR: ATTACH ADDITIONAL RESPONSIBILITIES DYNAMICALLY PARTIALLY IMPLEMENTED DECORATOR PATTERN %macro messyMacro(num,char); * Messy Macro; %put MessyMacro &num. &char.; %mend messyMacro; %macro decoratorBefore(parameters); %put Before; %messyMacro&parameters.; %mend decoratorBefore; % %macro d t B f decoratorBeforeAndAfter(parameters); A dAft ( t ) %put Before; %messyMacro&parameters.; %put After; %mend decoratorBeforeAndAfter; %macro decoratorAfter(parameters); %messyMacro&parameters.; %put After; %mend decoratorAfter; %decoratorBeforeAndAfter(parameters=(num=1,char=SAS));
  • 22. TEMPLATE METHOD: APPLY DISCIPLINE TO THE FUNCTIONS AVAILABLE INSIDE MACROS Template Method Pattern Key Features Intent Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Redefine the steps in an algorithm without changing the algorithm’s structure Problem There is a procedure or set of steps to follow that is consistent at one level of detail, but individual steps may have different implementations at a lower level of detail. Solution Allows for definition of substeps that vary while maintaining a consistent basic process. Consequences Templates provide a good platform for code reuse. They are also helpful in ensuring the required steps are implemented.
  • 23. TEMPLATE METHOD: APPLY DISCIPLINE TO THE FUNCTIONS AVAILABLE INSIDE MACROS %macro accessSAS(connectParameters,selectRecordParameters); %macro accessSQLServer(connectParameters,selectRecordParameters); %macro connectDB(num,char); %macro connectDB(num,char); %put SAS ConnectDB; %put SQL Server ConnectDB; %mend connectDB; %mend connectDB; %macro selectRecords(num,char); %macro selectRecords(num,char); %put SAS Record Selection; %put SQL Server Record Selection; %mend selectRecords; %mend selectRecords; %macro doQuery; %macro doQuery; * doQuery is the same for all macros; * doQuery is the same for all macros; %connectDB&connectparameters.; %connectDB&connectparameters.; %selectRecords&selectRecordParameters.; %selectRecords&selectRecordParameters.; %mend doQuery; %mend doQuery; %doQuery; %doQuery; %mend accessSAS; %mend accessSQLServer; PARTIALLY IMPLEMENTED TEMPLATE METHOD: Two different macros, same nested macros %accessSAS(connectParameters=(num=1,char=SAS), selectRecordParameters=(num=2,char=SAS)); %accessSQLServer(connectParameters=(num=1,char=SQLServer), selectRecordParameters=(num=2,char=SQLServer));
  • 24. ANALYSIS MATRIX: HIGH- HIGH- VOLUME MACRO PROCESSING Analysis Matrix Method Pattern Key Features Intent Provide a systematic way to surface varying dimensions of change. Problem Variations in the system need to be made explicit so that applying design patterns becomes easier. Solution Create a matrix which documents the concepts which are varying. p y g Matrix creation can help the developer discover the concepts that are varying, find points of commonality, and uncover missing requirements. Consequences The final design is optimized for the surfaced dimensions, and dimensions refactoring may be required if dimensions are added or removed.
  • 25. ANALYSIS MATRIX: HIGH- HIGH- VOLUME MACRO PROCESSING U.S. Sales Canadian Sales German Sales Calculate freight Combination Combination Combination Verify address Combination Combination Combination Calculate tax Combination Combination Combination Money Combination Combination Combination Dates Combination Combination Combination Maximum Combination Combination Combination weight Analysis Matrix Example (Shalloway and Trott, 2005, p. 286)
  • 26. Overview How to trick the SAS Macro Language Why design Wh d i patterns are useful f l Six specific design patterns General application development advice
  • 27. General Application Advice The Th examples ill l illustrate conceptual design ld i patterns The examples could be used as is, or combined with one another Consider upgrading to SAS/AF Most optionally licensed products represent procedures which extend base SAS
  • 28. Conclusion This presentation: p Provided tricks for object-oriented emulation object- Defined and defended design patterns Demonstrated fully or partially implemented design patterns Provided application advice Read more (books or web) on design patterns to deepen your topical understanding
  • 29. References Fowler, Martin (1999), Refactoring: Improving the Design of Existing Code, Code, Reading, MA: Addison Wesley Longman, Inc. Gamma, E., Helm, R., Johnson, R., Vlissides, J. (1995), Design Patterns: Elements of Reusable Object-Oriented Software, Reading MA: Object- Software, Reading, Addison Wesley Longman, Inc. SAS Institute Inc. (2005), SAS OnlineDoc® 9.1.3, Cary, NC: SAS 9.1.3, Institute, Inc. Shalloway, A., and Trott, J. (2005), Design Patterns Explained: a New Perspective on Object-Oriented Design (Second Edition), Boston MA: Object- Edition), Boston, Addison- Addison-Wesley, Inc. Tabladillo, M. (2005), “Macro Architecture in Pictures”, SUGI ( Proceedings, Proceedings, 2005.
  • 30. Contact Information Mark Tabladillo Software Developer, MarkTab C S f D l M kT b Consulting li http://www.marktab.com