mirror of
https://github.com/SASPAC/macroarray.git
synced 2025-12-12 19:04:34 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b3d058e75 | ||
|
|
620ff4a74f | ||
|
|
5c4ff371bf | ||
|
|
a211d86642 | ||
|
|
efbeae5a36 | ||
|
|
cf8a94fb25 | ||
|
|
613569560f | ||
|
|
bf2fa01d1d | ||
|
|
a7ef089a07 |
30
README.md
Normal file
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
### `macroArray` - Macroarrays for macro codes
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The **macroArray** package implements an array, a hash table, and a dictionary concept in macrolanguage. For example:
|
||||||
|
```sas
|
||||||
|
%array(ABC[17] (111:127), macarray=Y);
|
||||||
|
|
||||||
|
%macro test();
|
||||||
|
%do i = 1 %to 17;
|
||||||
|
%put &i.) %ABC(&i.);
|
||||||
|
%end;
|
||||||
|
%mend;
|
||||||
|
%test()
|
||||||
|
|
||||||
|
%let %ABC(13,i) = 99999; /* i = insert */
|
||||||
|
|
||||||
|
%do_over(ABC, phrase=%nrstr(
|
||||||
|
%put &_i_.%) %ABC(&_i_.);
|
||||||
|
),
|
||||||
|
which = 1:H:2
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
SHA256 digest for the latest version of `macroArray`: F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50
|
||||||
|
|
||||||
|
[**Documentation for macroArray**](./macroarray.md "Documentation for macroArray")
|
||||||
|
|
||||||
|
To work with a package use the [**SAS Packages Framework**](https://github.com/yabwon/SAS_PACKAGES/blob/main/README.md "SPFinit").
|
||||||
|
|
||||||
BIN
hist/1.0.2/macroarray.zip
Normal file
BIN
hist/1.0.2/macroarray.zip
Normal file
Binary file not shown.
BIN
hist/1.0.3/macroarray.zip
Normal file
BIN
hist/1.0.3/macroarray.zip
Normal file
Binary file not shown.
BIN
hist/1.0.4/macroarray.zip
Normal file
BIN
hist/1.0.4/macroarray.zip
Normal file
Binary file not shown.
BIN
hist/1.0.5/macroarray.zip
Normal file
BIN
hist/1.0.5/macroarray.zip
Normal file
Binary file not shown.
2199
hist/1.0.6/macroarray.md
Normal file
2199
hist/1.0.6/macroarray.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.0.6/macroarray.zip
Normal file
BIN
hist/1.0.6/macroarray.zip
Normal file
Binary file not shown.
2204
hist/1.1.0/macroarray.md
Normal file
2204
hist/1.1.0/macroarray.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.1.0/macroarray.zip
Normal file
BIN
hist/1.1.0/macroarray.zip
Normal file
Binary file not shown.
2204
hist/1.1.1/macroarray.md
Normal file
2204
hist/1.1.1/macroarray.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.1.1/macroarray.zip
Normal file
BIN
hist/1.1.1/macroarray.zip
Normal file
Binary file not shown.
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# The macroArray package [ver. 1.0.1] <a name="macroarray-package"></a> ###############################################
|
# The macroArray package [ver. 1.1.1] <a name="macroarray-package"></a> ###############################################
|
||||||
|
|
||||||
The **macroArray** package implements a macro array facility:
|
The **macroArray** package implements a macro array facility:
|
||||||
- `%array()`,
|
- `%array()`,
|
||||||
@@ -75,10 +75,10 @@ Package contains:
|
|||||||
Required SAS Components:
|
Required SAS Components:
|
||||||
*Base SAS Software*
|
*Base SAS Software*
|
||||||
|
|
||||||
*SAS package generated by generatePackage, version 20221112.*
|
*SAS package generated by generatePackage, version 20230904*
|
||||||
|
|
||||||
The SHA256 hash digest for package macroArray:
|
The SHA256 hash digest for package macroArray:
|
||||||
`371B92A5ABBE82C53F7D63BC5C0D1EBD4695603D3894D8A9A5D5777D1AB59B30`
|
`F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50`
|
||||||
|
|
||||||
---
|
---
|
||||||
# Content description ############################################################################################
|
# Content description ############################################################################################
|
||||||
@@ -278,6 +278,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
<,macarray=N>
|
<,macarray=N>
|
||||||
<,ds=>
|
<,ds=>
|
||||||
<,vars=>
|
<,vars=>
|
||||||
|
<,q=>
|
||||||
)
|
)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -312,8 +313,8 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
`%array(myArr[*] x1-x3 (4:6), vnames=Y)`
|
`%array(myArr[*] x1-x3 (4:6), vnames=Y)`
|
||||||
will use `x1`, `x2`, and `x3` as values instead `4`, `5`, and `6`.
|
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 a macro, named with the array
|
||||||
name is compiled to create convenient envelope for multiple ampersands, e.g.
|
name, is compiled to create convenient envelope for multiple ampersands, e.g.
|
||||||
`%array(myArr[*] x1-x3 (4:6), macarray=Y)`
|
`%array(myArr[*] x1-x3 (4:6), macarray=Y)`
|
||||||
will create `%myArr(J)` macro which will allow to extract "data"
|
will create `%myArr(J)` macro which will allow to extract "data"
|
||||||
from macroarray like:
|
from macroarray like:
|
||||||
@@ -325,8 +326,8 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
macrovariables with prefix like the array name and numeric suffixes,
|
macrovariables with prefix like the array name and numeric suffixes,
|
||||||
then the minimum and the maximum index is determined
|
then the minimum and the maximum index is determined
|
||||||
and all not existing global macrovariables are created and
|
and all not existing global macrovariables are created and
|
||||||
a macro is generated in the same way as for the `Y` value
|
a macro is generated in the same way as for the `Y` value.
|
||||||
|
|
||||||
* `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=`
|
if used by default overwrites use of the `array` parameter, honors `macarray=`
|
||||||
argument, dataset options are allowed, e.g. `sashelp.class(obs=5)`
|
argument, dataset options are allowed, e.g. `sashelp.class(obs=5)`
|
||||||
@@ -343,23 +344,27 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
2) macroarray "WEIGHT" with ALL(no separator is equivalent to #)
|
2) macroarray "WEIGHT" with ALL(no separator is equivalent to #)
|
||||||
values of variable "weight" <br>
|
values of variable "weight" <br>
|
||||||
3) macroarray "W" with UNIQUE(|) values of variable "weight" and <br>
|
3) macroarray "W" with UNIQUE(|) values of variable "weight" and <br>
|
||||||
4) macroarray "AGE" with UNIQUE(|) values of variable "age",
|
4) macroarray "AGE" with UNIQUE(|) values of variable "age".
|
||||||
|
|
||||||
|
* `q=` - *Optional*, indicates (when set to `1`) if the value be surrounded by quotes.
|
||||||
|
It uses `quote(cats(...))` combo under the hood. Default value is `0`.
|
||||||
|
Ignored for `macarray=M`.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### EXAMPLES AND USECASES: ####################################################
|
### EXAMPLES AND USECASES: ####################################################
|
||||||
|
|
||||||
|
|
||||||
**EXAMPLE 1.** Basic use-case.
|
**EXAMPLE 1.** Basic use-case.
|
||||||
Creating macroarray like in the array statement;
|
Creating macroarray like in the array statement.
|
||||||
values are used by default;
|
Values not variables names are used by default.
|
||||||
different types of brackets are allowed;
|
Different types of brackets are allowed.
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
%array(a[*] x1-x5 (1:5))
|
%array(a[*] x1-x5 (1:5))
|
||||||
|
|
||||||
%array(b{5} (5*17))
|
%array(b{5} (5*17), q=1)
|
||||||
|
|
||||||
%* Mind the $ since it is a character array!;
|
%* Mind the $ since it is a character array!;
|
||||||
%array(c(3) $ 10 ("a A" "b,B" "c;C"))
|
%array(c(3) $ 10 ("a A" "b,B" "c;C"))
|
||||||
@@ -405,7 +410,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
%put &=g0. &=g1. &=g2.;
|
%put &=g0. &=g1. &=g2.;
|
||||||
|
|
||||||
%* Or something more complex;
|
%* Or something more complex;
|
||||||
%array(gg[0:11] $ 11, function = put(intnx("MONTH", '1jun2018'd, _I_, "E"), yymmn.))
|
%array(gg[0:11] $ 11, function = put(intnx("MONTH", '1jun2018'd, _I_, "E"), yymmn.), q=1)
|
||||||
%put &=ggLBOUND. &=ggHBOUND. &=ggN.;
|
%put &=ggLBOUND. &=ggHBOUND. &=ggN.;
|
||||||
%put &=gg0 &=gg1 &=gg2 ... &=gg11;
|
%put &=gg0 &=gg1 &=gg2 ... &=gg11;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -433,10 +438,10 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
**EXAMPLE 6a.** "Uppercas Letters"
|
**EXAMPLE 6a.** Quoted "Uppercas Letters"
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
%array(UL[26] $, function = byte(rank("A")+_I_-1) )
|
%array(UL[26] $, function = byte(rank("A")+_I_-1) , q=1)
|
||||||
%put &=UL1 &=UL2 ... &=UL25 &=UL26;
|
%put &=UL1 &=UL2 ... &=UL25 &=UL26;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -451,7 +456,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
|
|
||||||
%* The range handling, warning;
|
%* The range handling, warning;
|
||||||
%put *%ll(265)*;
|
%put *%ll(265)*;
|
||||||
|
|
||||||
%* The input mode;
|
%* The input mode;
|
||||||
%put *before:*%ll(2)*;
|
%put *before:*%ll(2)*;
|
||||||
%let %ll(2,I) = bbbbb;
|
%let %ll(2,I) = bbbbb;
|
||||||
@@ -576,10 +581,10 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
Currently the only separator in VARS is a space.
|
Currently the only separator in VARS is a space.
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
%array(ds = sashelp.class, vars = height#h weight weight|w age|)
|
%array(ds = sashelp.class, vars = height#h weight weight|w age|, q=1)
|
||||||
%put _user_;
|
%put _user_;
|
||||||
|
|
||||||
%array(ds = sashelp.class, vars = height#hght weight weight|wght age|, macarray=Y)
|
%array(ds = sashelp.class, vars = height#hght weight weight|wght age|, macarray=Y, q=1)
|
||||||
%put *%hght(&hghtLBOUND.)**%weight(2)**%wght(&wghtHBOUND.)**%age(3)*;
|
%put *%hght(&hghtLBOUND.)**%weight(2)**%wght(&wghtHBOUND.)**%age(3)*;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@@ -599,7 +604,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
%let myTest6 = 16;
|
%let myTest6 = 16;
|
||||||
%let myTest9 = 19;
|
%let myTest9 = 19;
|
||||||
|
|
||||||
%array(myTest, macarray=M)
|
%array(myTest, macarray=M, q=1)
|
||||||
%do_over(myTest, phrase = %nrstr(%put *&_I_.*%myTest(&_I_.)*;))
|
%do_over(myTest, phrase = %nrstr(%put *&_I_.*%myTest(&_I_.)*;))
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
BIN
macroarray.zip
BIN
macroarray.zip
Binary file not shown.
Reference in New Issue
Block a user