Wednesday, November 4, 2015

pattern1.ENCAPSULATION

/*
ENCAPSULATION
Encapsulation describes the ability of the SAS macro to hide the
definition of variables and methods inside a macro
ref:
E:\ChenyxFiles\2014.Study.TrainingCertificate\SAS.Victoria\SAS.DS2\SASUniversityEdition\myfolders\DesignPattern\DependencyInversion\++++read.Toward Object-Oriented Macros in SAS.pdf

TIP ONE: MAKE SAS MACRO VARIABLES AS LOCAL AS POSSIBLE
TIP TWO: NEST SAS MACROS WHEN LOCAL BINDING MAKES SENSE
Parse dynamic number of variables to macro call different functions
Autocall macros
TIP SIX: CONDITIONALLY DEFINE NESTED SAS MACROS
The %INCLUDE for inherit macro

business layer
db layer
Ui layer

*/

proc sql;
select * from DICTIONARY.MACROS where scope='GLOBAL';
quit;

/*Nested Macro Example*/
%macro stats1(product,year);

%macro title;
title "Statistics for &product in &year";
%if &year>1929 and &year<1935 %then
%do;
title2 "Some Data Might Be Missing";
%end;
%mend title;

proc means data=products;
where product="&product" and year=&year;

%title
run;
%mend stats1;

%stats1(steel,2002)
%stats1(beef,2000)
%stats1(fiberglass,2001)


No comments:

Post a Comment