Releases: SASPAC/macroarray
The macroArray package [ver. 1.3.0]
The macroArray package [ver. 1.3.0]
Changes:
- Four new parameters in the
%do_over()macro:check,rephrase,trigger, andunq. See "Details" section below. - Minor updates in the
%array()macro. - Documentation updated and refreshed.
SHA256 hash digest: F*FFF2C3D854F9B5677F561BA2EB6FAA2CCC652D81F6AF9473ADF0A4CE977E43F0
Details:
The new parameters were design to make work with the %do_over() macro easier.
New parameters
-
check=- Optional, indicates should a check for a macro corresponding to a macroarray be executed. If the macro does not exist warning is issued and thedo_overstops. Default value0means: do not execute check. -
rephrase=- Optional, this parameter allows for an alternative approach in providing the phrase to be looped over. The idea is to make writing the phrase string code more convenient and easy to grasp. The value is a string containing triggers (symbols) that are
replaced by proper macroarray calls. For example, if a macroarraymyArrhas 7 values formvarName1tovarName7and you want
to use them as arguments in code renaming variables, sayrename old_varName1=new_varName1 ... ;, instead typing phrase:rename %do_over(myArr,phrase=%nrstr(old_%myArr(&_I_.)=new_%myArr(&_I_.)));you can type much easier rephrase:rename %do_over(myArr,rephrase=old_?=new_?);, and all?will be replaced, under the hood, by calls to the macroarray. For easier debugging thedo_overmacro prints the rephrased string before and after change. When thedo_overloops with multiple array, saymyArrA,myArrB, andmyArrC, then those arrays should be referred by?1?,?2?, and?3?respectively. Seetriggerparameter definition to learn more. If bothphraseandrephraseare used, the second takes precedence. -
trigger=- Optional, a single byte character (symbol) used for marking macroarrays in the newly created phrase. Default value is?symbol. When one macroarray is used, only the symbol should be used inrephrase=string. When multiple macroarrays are used then the symbol should surround a number identifying array, e.g.?2?. See examples below for details. -
unq=- Optional, indicates that the%unquote()macro function should be added around every macroarray call. Because of SAS internal behaviorunq=1is needed for certain cases when plain 4GL code is used inrephrase=. For example, let macro arraymyArr()has 3 values:A1,B2, andC3. When the following code is run:%do_over(myArr, rephrase=data ?_test; run;)withoutunq=1, SAS will create 4 data sets:A1,B2,C3, and_test, instead 3 data sets:A1_test,B2_test, andC3_test. Default value1means: add the%unquote(). See example below to learn more.
Examples:
EXAMPLE 1. Simpler multiple arrays looping with rephrase=.
%array(alpha[*] j k l m n o p, vnames=Y, macarray=Y)
%array( beta[&alphaN.], function = (2**_i_), macarray=Y)
%array(gamma[&alphaN.] (1:&alphaN.), macarray=Y)
%put >>%do_over(alpha)<<;
%put >>%do_over(beta)<<;
%put >>%do_over(gamma)<<;
data test8;
call streaminit(123);
%do_over( alpha beta gamma
, rephrase = ?1? = ?2? + ?3? * rand('Uniform'); output;
, between = put _all_;
)
put _all_;
run;EXAMPLE 2. Simpler multiple arrays looping with rephrase=, cont.
Create multiple datasets. Array alpha, beta, and gamma are
from the previous example.
%do_over(alpha beta gamma
, rephrase =
data ?1?_2;
call streaminit(?2?);
?1?X = ?2? + ?3? * rand('Uniform');
output;
run;
)EXAMPLE 3. Simpler multiple arrays looping with rephrase=, cont.
Create multiple datasets using a macro. Array alpha, beta,
and gamma are from the previous example.
The %nrstr() is required to mask call to the %doit2() macro.
Default ? is replaced with @.
%macro doit2(ds, var=a, val1=1, val2=2);
data &ds._3;
call streaminit(&val1.);
&var. = &val1. + &val2. * rand('Uniform');
output;
run;
%mend doit2;
%do_over( alpha beta gamma
, rephrase = %nrstr(%doit2(@1@, var = @1@, val1 = @2@, val2 = @3@))
, trigger = @
)EXAMPLE 4. Simpler multiple arrays looping with rephrase=, cont.
Why the unq= is needed.
%array(myArr[3] $ ("A1" "B2" "C3"), macarray=Y)
%do_over(myArr, rephrase=data ?_testUNQ1; run;, unq=1)
%do_over(myArr, rephrase=data ?_testUNQ0; run;, unq=0)EXAMPLE 5. Simpler multiple arrays looping with rephrase=, cont.
Renaming variables is easy now.
%array(V[*] a b c d e f g h, vnames=1, macarray=1)
data test12;
array x{*} %do_over(V) (1:&VN.);
run;
proc datasets nolist noprint lib=work;
modify test12;
rename
%do_over(V,rephrase = $=new_$,trigger=$)
;
run;
quit;
data _null_;
set test12;
put _ALL_;
run;The macroArray package [ver. 1.2.6]
The macroArray package [ver. 1.2.6]
Changes:
- Minor update in
%mcDictionary()and%mcHashTable()macros. Restrictions for object names check updated. - Documentation updated.
SHA256 digest for the latest version macroArray: F*3F3893F1FCD78719543703E4353F4CC19811D247C016F220FF729B283C1AD790
The macroArray package [ver. 1.2.5]
The macroArray package [ver. 1.2.5]
Changes:
- Bug fix in the
%concatArrays()macro. - Spelling fix in log message of the
%make_do_over()macro.
SHA256 hash digest: F*FFF2C3D854F9B5677F561BA2EB6FAA2CCC652D81F6AF9473ADF0A4CE977E43F0
The macroArray package [ver. 1.2.3]
The macroArray package [ver. 1.2.3]
- Update in
q=parameter for the%array()macro. - Fix in data set existence for
ds=parameter in the%array()macro. - Documentation updated.
SHA256 digests for macroArray: F*A0840B92EB9356EDB318DBE9B579A345C85ABF69E8D5F7C73C144C66F2F74FB4
The macroArray package [ver. 1.2.1]
The macroArray package [ver. 1.2.1]
Package regenerated with the latest version of the SAS Packages Framework (20231111).
SHA256 digests for macroArray: F*2A108D121D4DACAA8752E681301371F80F0500B2EE28A9E3B39678415BCBD6B2
The macroArray package [ver. 1.2.0]
The macroArray package [ver. 1.2.0]
- New parameters added to the
%mcDictionary()macro which allows to populate dictionary directly from a data set (see the last example in the documentation). - Documentation updated.
SHA256 digest for the latest version of macroArray: F*8689194590698F9A00B57FB37BE3CA8D7330F16B3E591CEAF49E6BE0B70D61D0
The macroArray package [ver. 1.1.1]
The macroArray package [ver. 1.1.1]
Changes:
- bug fixes.
- code optimization.
The SHA256 hash digest for package macroArray:
F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50
The macroArray package [ver. 1.1.0]
The macroArray package [ver. 1.1.0]
Updates
New parameter in the %array() macro:
q=- Optional, indicates (when set to1) if the value be surrounded by quotes. It usesquote(cats(...))combo under the hood. Default value is0. Ignored formacarray=M.
Documentation updated.
SHA256 for macroArray is: F*6A22A01868F4203862B3685F543D723C7DB8E9AB3C1A6357D2BFA030971B0D3C
Example:
%array(UL[26] $, function = byte(rank("A")+_I_-1) , q=1)
%put &=UL1 &=UL2 ... &=UL25 &=UL26;The macroArray package [ver. 1.0.6]
The macroArray package [ver. 1.0.6]
Package regenerated with the latest version of the SAS Packages Framework (20230904).
SHA256 digest for the latest version of macroArray: F*4FAAEE7DF2854EA31933AE017A89C1615C7291A66A07CCE345041EB0D587ED4E
The macroArray package [ver. 1.0.5]
The macroArray package [ver. 1.0.5]
- Package regenerated with the latest version of the SAS Packages Framework (20230411).