macroArray, version 0.5

macroArray, version 0.5
- documentation updated, macroarray.md created
- the do_overs automatically unquote `betwee=` parameter
This commit is contained in:
yabwon
2020-09-15 12:15:37 +02:00
parent 5c640cba21
commit 8c584c8030
5 changed files with 126 additions and 108 deletions

View File

@@ -98,7 +98,7 @@ SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713
which = 1:H:2
);
```
SHA256 digest for macroArray: ACE3E9374256826AB1E25C2BBDA6CA4CCFB50137B8ACE6E1F11BCDBE7AE24B09
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")

View File

@@ -68,7 +68,7 @@ SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713
which = 1:H:2
);
```
SHA256 digest for macroArray: ACE3E9374256826AB1E25C2BBDA6CA4CCFB50137B8ACE6E1F11BCDBE7AE24B09
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")

View File

@@ -1,5 +1,5 @@
/* 20200914 */
macroArray: ACE3E9374256826AB1E25C2BBDA6CA4CCFB50137B8ACE6E1F11BCDBE7AE24B09
macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
/* 20200914 */
SQLinDS: DD5E319EB5AA29C7054EC428072F987E77C29D36874DED1AE5C62E4B300845EB

View File

@@ -63,12 +63,12 @@ Required SAS Components:
*SAS package generated by generatePackage, version 20200911*
The SHA256 hash digest for package macroArray:
`ACE3E9374256826AB1E25C2BBDA6CA4CCFB50137B8ACE6E1F11BCDBE7AE24B09`
`53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35`
---
# Content description ############################################################################################
## >>> `%appendArray()` macro: <<< <a name="appendarray-macro"></a> ##############################################
## >>> `%appendArray()` macro: <<< <a name="appendarray-macro"></a> ############
The `%appendArray()` macro is a macrowrapper
which allows to concatenate two macroarrays
@@ -80,7 +80,7 @@ Dimensions of the first macroarray are extended.
The `%appendArray()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -92,13 +92,14 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. first - *Required*, a name of a macroarray created by the `%array()` macro.
1. `first` - *Required*, a name of a macroarray created by the `%array()` macro.
2. second - *Required*, a name of a macroarray created by the `%array()` macro.
2. `second` - *Required*, a name of a macroarray created by the `%array()` macro.
### EXAMPLES AND USECASES: ####################################################
### EXAMPLES AND USECASES: ######################################################
**EXAMPLE 1.** Append macroarrays LL and MM.
@@ -130,8 +131,9 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%appendCell()` macro: <<< <a name="appendcell-macro"></a> ###############################################
## >>> `%appendCell()` macro: <<< <a name="appendcell-macro"></a> ##############
The `%appendCell()` macro allows to append
a macrovariable to a macroarray created by the `%array()` macro.
@@ -140,7 +142,7 @@ Dimensions of the macroarray are extended.
The `%appendCell()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: ####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -153,15 +155,16 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. first - *required*, a name of a macroarray created by the `%array()` macro.
1. `first` - *Required*, a name of a macroarray created by the `%array()` macro.
2. second - *required*, a name of a macrovariable to be append to the macroarray.
2. `second` - *Required*, a name of a macrovariable to be append to the macroarray.
3. hilo - *required*, if `H` macrovariable is appended at the end
if `L` macrovariable is appended at the beginning
3. `hilo` - *Required*, if `H` macrovariable is appended at the end
if `L` macrovariable is appended at the beginning
);
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Create two macro wrappers.
@@ -218,7 +221,8 @@ The basic syntax is the following, the `<...>` means optional parameters:
---
## >>> `%array()` macro: <<< <a name="array-macro"></a> ####################################################
## >>> `%array()` macro: <<< <a name="array-macro"></a> #######################
The code of a macro was inspired by
*Ted Clay's* and *David Katz's* macro `%array()`.
@@ -264,7 +268,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. `array` - *Mandatory*, an array name and a declaration/definition of an array, <br>
1. `array` - *Required*, an array name and a declaration/definition of an array, <br>
e.g. `myArr[*] x1-x3 (4:6)` <br>
or `myBrr[*] $ y1-y3 ("a" "b" "c")` <br>
or `myCrr[3] $ ("d d d" "e,e,e" "f;f;f")` <br>
@@ -288,12 +292,12 @@ The basic syntax is the following, the `<...>` means optional parameters:
* `after=` - *Optional*, a function or an expression to be added after looping through
array, e.g. `call sortn(ABC)`.
* `vnames=N` - *Optional*, Default value `N`, if set to `Y`/`YES` then macroarray is built based
* `vnames=N` - *Optional*, default value `N`, if set to `Y`/`YES` then macroarray is built based
on variables names instead values, e.g.
`%array(myArr[*] x1-x3 (4:6), vnames=Y)`
will use `x1`, `x2`, and `x3` as values instead `4`, `5`, and `6`.
* `macarray=N` - *Optional*, Default value `N`, if set to `Y`/`YES` then macro named with array
* `macarray=N` - *Optional*, default value `N`, if set to `Y`/`YES` then macro named with array
name is compiled to create convenient envelope for multiple ampersands, e.g.
`%array(myArr[*] x1-x3 (4:6), macarray=Y)`
will create `%myArr(J)` macro which will allow to extract "data"
@@ -303,7 +307,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
value:
`%let %myArr(17,i) = 42;`
* `ds=` - *Optional*, Use a dataset as a basis for a macroarray data,
* `ds=` - *Optional*, use a dataset as a basis for a macroarray data,
if used by default overwrites use of the `array` parameter, honors `macarray=`
argument, dataset options are allowed, e.g. `sashelp.class(obs=5)`
@@ -322,6 +326,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
4) macroarray "AGE" with UNIQUE(|) values of variable "age",
### EXAMPLES AND USECASES: ####################################################
@@ -567,8 +572,9 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%concatArrays()` macro: <<< <a name="concatarrays-macro"></a> #############################################
## >>> `%concatArrays()` macro: <<< <a name="concatarrays-macro"></a> ###########
The `%concatArrays()` macro allows to concatenate
two macroarrays created by the `%array()` macro.
@@ -579,7 +585,7 @@ Dimensions of the first macroarray are extended.
The `%concatArrays()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -592,12 +598,13 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. first - *Required*, a name of a macroarray created by the `%array()` macro.
1. `first` - *Required*, a name of a macroarray created by the `%array()` macro.
2. second - *Required*, a name of a macroarray created by the `%array()` macro.
2. `second` - *Required*, a name of a macroarray created by the `%array()` macro.
* `removeSecond=Y` - *Optional*, default value `Y`, if set to `Y` then
the second array is removed.
* removeSecond=Y - *Optional*, Default value `Y`, if set to `Y` then
the second array is removed.
@@ -633,15 +640,16 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%deleteMacArray()` macro: <<< <a name="deletemacarray-macro"></a> ###########################################
## >>> `%deleteMacArray()` macro: <<< <a name="deletemacarray-macro"></a> #######
The `%deleteMacArray()` macro allows to delete
macroarrays created by the `%array()` macro.
The `%deleteMacArray()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -653,26 +661,27 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. arrs - *Required*, a space separated list of manes
of macroarray created by the `%array()` macro.
1. `arrs` - *Required*, a space separated list of manes
of macroarray created by the `%array()` macro.
* `macarray=N` - *Optional*, indicator should a macro
associated with macroarray to be deleted?
If `Y` or `YES` then the associated macro is deleted.
* macarray=N - *Optional*, indicator should a macro
associated with macroarray to be deleted?
If `Y` or `YES` then the associated macro is deleted.
## >>> `%do_over()` macro: <<< <a name="do-over-macro"></a>################################################
## >>> `%do_over()` macro: <<< <a name="do-over-macro"></a>######################
The code of the macro was inspired by
*Ted Clay's* and *David Katz's* macro `%do_over()`.
The `%DO_OVER()` macro allows to iterate over macroarray created with the `macarray=Y`
parameter of the `%ARRAY()` macro.
The `%DO_OVER()` macro allows to iterate over macroarray created with
the `macarray=Y` parameter of the `%ARRAY()` macro.
The `%do_over()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -686,29 +695,30 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. array - Required, indicates a macroarray which metadata (Lbound, Hbouns)
are to be used to loop in the `%do_over()`
1. `array` - *Required*, indicates a macroarray which metadata (Lbound, Hbouns)
are to be used to loop in the `%do_over()`
* phrase= - *Optional*, Default value `%nrstr(%&array(&_I_.))`,
a statement to be called in each iteration
of the internal do_over's loop. Loop iterator is `_I_`,
if you want to use `_I_` or array name
[e.g. `%myArr(&_I_.)`] *enclose it* in the `%NRSTR()`
macro quoting function.
* `phrase=` - *Optional*, Default value `%nrstr(%&array(&_I_.))`,
a statement to be called in each iteration
of the internal do_over's loop. Loop iterator is `_I_`,
if you want to use `_I_` or array name
[e.g. `%myArr(&_I_.)`] *enclose it* in the `%NRSTR()`
macro quoting function.
* between= - *Optional*, Default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
* `between=` - *Optional*, default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
* `which=` - *Optional*, a _SPACE_ separated list of indexes which
should be used to iterate over selected macroarray.
Possible special characters are `H` and `L` which means
*high* and *low* bound of an array, list could be set with
colons(`:`) in form of `start:end:by` (*no spaces between!*),
if `by` is omitted the default is `1`. If possible use
`1:5` rather `1 2 3 4 5` since the firs works faster.
* which = - *Optional*, a _SPACE_ separated list of indexes which
should be used to iterate over selected macroarray.
Possible special characters are `H` and `L` which means
*high* and *low* bound of an array, list could be set with
colons(`:`) in form of `start:end:by` (*no spaces between!*),
if `by` is omitted the default is `1`. If possible use
`1:5` rather `1 2 3 4 5` since the firs works faster.
### EXAMPLES AND USECASES: ####################################################
@@ -840,18 +850,19 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%do_over2()` macro: <<< <a name="do-over2-macro"></a>################################################
## >>> `%do_over2()` macro: <<< <a name="do-over2-macro"></a>####################
The code of the macro was inspired by
*Ted Clay's* and *David Katz's* macro `%do_over()`.
The `%DO_OVER2()` macro allows to iterate over *two* macroarray created with the `macarray=Y`
parameter of the `%ARRAY()` macro.
The `%DO_OVER2()` macro allows to iterate over *two* macroarray created with
the `macarray=Y` parameter of the `%ARRAY()` macro.
The `%do_over2()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -865,25 +876,26 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. arrayI - Required, indicates the first macroarray which metadata (Lbound, Hbouns)
are to be used in the outer loop in the `%do_over2()`
1. `arrayI` - Required, indicates the first macroarray which metadata (Lbound, Hbouns)
are to be used in the outer loop in the `%do_over2()`
2. arrayJ - Required, indicates the second macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over2()`
2. `arrayJ` - Required, indicates the second macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over2()`
* phrase= - *Optional*, Default value `%nrstr(%&arrayI(&_I_.) %&arrayJ(&_J_.))`,
a statement to be called in each iteration
of the *inner* loop. The outer loop iterator is `_I_`,
the inner loop iterator is `_J_`,
if you want to use `_I_`, `_J_`, or arrays names
[e.g. `%myArr(&_I_.)`] *enclose them* in the `%NRSTR()`
macro quoting function.
* `phrase=` - *Optional*, default value `%nrstr(%&arrayI(&_I_.) %&arrayJ(&_J_.))`,
a statement to be called in each iteration
of the *inner* loop. The outer loop iterator is `_I_`,
the inner loop iterator is `_J_`,
if you want to use `_I_`, `_J_`, or arrays names
[e.g. `%myArr(&_I_.)`] *enclose them* in the `%NRSTR()`
macro quoting function.
* `between=` - *Optional*, default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over2 loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
* between= - *Optional*, Default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over2 loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
@@ -931,18 +943,19 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%do_over3()` macro: <<< <a name="do-over3-macro"></a>################################################
## >>> `%do_over3()` macro: <<< <a name="do-over3-macro"></a>####################
The code of the macro was inspired by
*Ted Clay's* and *David Katz's* macro `%do_over()`.
The `%DO_OVER3()` macro allows to iterate over *three* macroarray created with the `macarray=Y`
parameter of the `%ARRAY()` macro.
The `%DO_OVER3()` macro allows to iterate over *three* macroarray created with
the `macarray=Y` parameter of the `%ARRAY()` macro.
The `%do_over3()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -957,28 +970,29 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
1. arrayI - Required, indicates the first macroarray which metadata (Lbound, Hbouns)
are to be used in the outer loop in the `%do_over3()`
1. `arrayI` - *Required*, indicates the first macroarray which metadata (Lbound, Hbouns)
are to be used in the outer loop in the `%do_over3()`
2. arrayJ - Required, indicates the second macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over3()`
2. `arrayJ` - *Required*, indicates the second macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over3()`
3. arrayK - Required, indicates the third macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over3()`
3. `arrayK` - *Required*, indicates the third macroarray which metadata (Lbound, Hbouns)
are to be used in the inner loop in the `%do_over3()`
* phrase= - *Optional*, Default value `%nrstr(%&arrayI(&_I_.) %&arrayJ(&_J_.) %&arrayK(&_K_.))`,
a statement to be called in each iteration
of the *inner* loop. The *outer* loop iterator is `_I_`,
the *middle* loop iterator is `_J_`, the *inner* loop iterator is `_K_`,
if you want to use `_I_`, `_J_`, `_K_`, or arrays names
[e.g. `%myArr(&_I_.)`] *enclose them* in the `%NRSTR()`
macro quoting function.
* `phrase=` - *Optional*, default value `%nrstr(%&arrayI(&_I_.) %&arrayJ(&_J_.) %&arrayK(&_K_.))`,
a statement to be called in each iteration
of the *inner* loop. The *outer* loop iterator is `_I_`,
the *middle* loop iterator is `_J_`, the *inner* loop iterator is `_K_`,
if you want to use `_I_`, `_J_`, `_K_`, or arrays names
[e.g. `%myArr(&_I_.)`] *enclose them* in the `%NRSTR()`
macro quoting function.
* `between=` - *Optional*, default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over2 loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
* between= - *Optional*, Default value `%str( )` (space),
a statement to be called in between each
iteration of the internal do_over2 loop.
If macroquoted (e.g. `%str( + )`) then the `%unquote()`
function is automatically applied.
@@ -1007,8 +1021,9 @@ The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%make_do_over()` macro: <<< <a name="make-do-over-macro"></a> ###########################################
## >>> `%make_do_over()` macro: <<< <a name="make-do-over-macro"></a> ###########
The code of the macro was inspired by
*Ted Clay's* and *David Katz's* macro `%do_over()`.
@@ -1018,7 +1033,7 @@ the `%DO_OVER<n>()` macros. It works *only* for *n>3*!
The `%make_do_over()` macro does *not* executes like a pure macro code.
### SYNTAX: ###################################################################
### SYNTAX: #####################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
@@ -1029,14 +1044,15 @@ The basic syntax is the following, the `<...>` means optional parameters:
**Arguments description**:
size - Required, indicates the number of dimensions
(i.e. inner loops) of the `%DO_OVER<n>()` macro.
1. `size` - *Required*, indicates the number of dimensions
(i.e. inner loops) of the `%DO_OVER<n>()` macro.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Code of created "4-loop" %DO_OVER4() macro
**EXAMPLE 1.** Code of created "4-loop" `%DO_OVER4()` macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%macro do_over4(
@@ -1072,7 +1088,7 @@ size - Required, indicates the number of dimensions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Create a 4-loop `%DO_OVER4()` macro
**EXAMPLE 3.** Create a "4-loop" `%DO_OVER4()` macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%make_do_over(4);
@@ -1088,7 +1104,7 @@ size - Required, indicates the number of dimensions
)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Create a 5-loop `%DO_OVER5()` macro
**EXAMPLE 3.** Create a "5-loop" `%DO_OVER5()` macro
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%make_do_over(5);
@@ -1147,4 +1163,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
---

Binary file not shown.