Compare commits

...

4 Commits

Author SHA1 Message Date
Bart Jablonski
e3b86f1157 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`
2023-09-21 21:26:09 +02:00
Bart Jablonski
c9b388b661 The BasePlus package [ver. 1.30.0]
The BasePlus package [ver. 1.30.0]

- new macro `%repList()` added
- doc. updated

SHA256 digest: `F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F`
2023-09-19 17:43:54 +02:00
Bart Jablonski
82681a3f91 Update README.md 2023-09-12 12:50:28 +02:00
Bart Jablonski
cb4f82eac9 The macroArray package [ver. 1.1.0]
The macroArray package [ver. 1.1.0]

New parameter in the `%array()` macro:
* `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`.
2023-09-06 23:09:40 +02:00
7 changed files with 197 additions and 33 deletions

View File

@@ -51,7 +51,7 @@ The first step to use a package with the SAS Packages Framework:
- Create a folder for your packages, under Windows OS family e.g., `C:/SAS_PACKAGES` or under Linux/UNIX OS family e.g., `/home/<username>/SAS_PACKAGES`.
and then either:
Then either:
- Manually download the `SPFinit.sas` file (the SAS Packages Framework) into the local packages folder.
- \[Optional\] Manually download the `<packageName>.zip` file into the local packages folder.
@@ -88,6 +88,13 @@ or do it pragmatically:
```sas
filename SPFinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas";
%include SPFinit; /* enable the framework */
```
or (shorter) with:
```sas
filename SPFinit url "https://bit.ly/SPFinit";
%include SPFinit; /* enable the framework */
```
- Install the framework on your machine in the folder you created:
@@ -97,7 +104,7 @@ filename packages "<directory/containing/packages/>";
%installPackage(SPFinit) /* install the framework */
```
- And from now on run it like this:
- From now on run it like this:
```sas
filename packages "<directory/containing/packages/>";
@@ -109,7 +116,8 @@ filename packages "<directory/containing/packages/>";
```
---
The "Workshop video for the User" got outdated (in general). Newer version is comming soon, in the mean time see some of the vedeos from the "Recordings and Presentations" section above.
The "Workshop video for the User" got outdated (in general). Newer version is coming soon, in the mean time see some of the videos from the "Recordings and Presentations" section above.
(You can watch the workshop if you wish, link is working and some parts are still valid source of information e.g., "`ICE` loading" or "`disk` loading")
<s>[**Workshop video for the User**](https://youtu.be/qX_-HJ76g8Y) \[May 6th, 2020\] [~86 minutes, outdated (installPackage macro was not there yet) but gives the idea how it works especially load, help, unload, ICEload, and other details]</s>
@@ -128,7 +136,7 @@ To create your own package:
- Read the **`My First SAS Package: A How-To - Paper 1079-2021`** article available at communities.sas.com [**`here`**](https://communities.sas.com/t5/SAS-Global-Forum-Proceedings/My-First-SAS-Package-A-How-To/ta-p/726319 "My First SAS Package: A How-To") or locally [**`here`**](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/Paper_1079-2021/My%20First%20SAS%20Package%20-%20a%20How%20To.pdf "My First SAS Package: A How-To")
The SAS Packages Framework [(short) documetation](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/SPFinit.md) to quickly see macros options and parametera.
The SAS Packages Framework [(short) documentation](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/SPFinit.md) to quickly see macros options and parameters.
---

View File

@@ -61,7 +61,7 @@ SHA256 digest for DFA: F*09EA5201360922A91A9EEE72F4567792E9CFDFB591BA33419E2BF2B
---
- **macroArray**\[1.0.6\], implementation of an array concept in a macro language, e.g.
- **macroArray**\[1.1.1\], implementation of an array concept in a macro language, e.g.
```sas
%array(ABC[17] (111:127), macarray=Y);
@@ -80,13 +80,13 @@ SHA256 digest for DFA: F*09EA5201360922A91A9EEE72F4567792E9CFDFB591BA33419E2BF2B
which = 1:H:2
);
```
SHA256 digest for macroArray: F*4FAAEE7DF2854EA31933AE017A89C1615C7291A66A07CCE345041EB0D587ED4E
SHA256 digest for macroArray: F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/macroarray.md "Documentation for macroArray")
---
- **BasePlus**\[1.29.1\] adds a bunch of functionalities I am missing in BASE SAS, such as:
- **BasePlus**\[1.30.0\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```sas
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -110,7 +110,7 @@ format x bool.;
%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$);
```
SHA256 digest for BasePlus: F*2FE68DD9B3692B9D46EF85B82F63C7E65010BF9E89D670FD1779F4670FA03F31
SHA256 digest for BasePlus: F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")

View File

@@ -1,3 +1,12 @@
/* 20230921 */
macroArray: F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50
/* 20230919 */
BasePlus: F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F
/* 20230906 */
macroArray: F*6A22A01868F4203862B3685F543D723C7DB8E9AB3C1A6357D2BFA030971B0D3C
/* 20230904 */
BasePlus: F*2FE68DD9B3692B9D46EF85B82F63C7E65010BF9E89D670FD1779F4670FA03F31
DFA: F*09EA5201360922A91A9EEE72F4567792E9CFDFB591BA33419E2BF2B31D9B7C62

View File

@@ -52,6 +52,7 @@
* [`%bpPIPE()` macro](#bppipe-macro)
* [`%dirsAndFiles()` macro](#dirsandfiles-macro)
* [`%repeatTxt()` macro](#repeattxt-macro)
* [`%repList()` macro](#replist-macro)
* [`%intsList()` macro](#intslist-macro)
* [`%letters()` macro](#letters-macro)
* [`%splitDSIntoBlocks()` macro](#splitdsintoblocks-macro)
@@ -72,7 +73,7 @@
---
# The BasePlus package [ver. 1.29.1] <a name="baseplus-package"></a> ###############################################
# The BasePlus package [ver. 1.30.0] <a name="baseplus-package"></a> ###############################################
The **BasePlus** package implements useful
functions and functionalities I miss in the BASE SAS.
@@ -309,6 +310,33 @@ run;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 22** Repeating texts and lists:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options mprint;
data work.A;
x=17;
data work.B;
x=42;
data work.C;
x=303;
run;
data work.test5;
set
%repeatTxt(work.A work.B work.C, 5)
;
run;
data Times2_A3B4C5;
set
%repList(work.A work.B work.C, times = 2, each = 3 4 5)
;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
Package contains:
@@ -375,9 +403,11 @@ Package contains:
61. macro letters
62. macro libpath
63. macro minclude
64. macro translate
65. macro tranwrd
66. macro workpath
64. macro replist
65. macro translate
66. macro tranwrd
67. macro workpath
@@ -388,7 +418,7 @@ localization (only if additional content was deployed during the installation pr
* SAS package generated by generatePackage, version 20230905 *
The SHA256 hash digest for package BasePlus:
`F*2FE68DD9B3692B9D46EF85B82F63C7E65010BF9E89D670FD1779F4670FA03F31`
`F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F`
---
# Content description ############################################################################################
@@ -4399,6 +4429,118 @@ run;
---
## >>> `%repList()` macro: <<< <a name="replist-macro"></a> #######################
The repList() macro function allows to repeat `T`
times elements of a `L` list, possibly `E` times each element,
separated by string `S`.
See examples below for the details.
The `%repList()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%repList(
list
<,times=>
<,each=>
<,lenghtOut=>
<,sep=>
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - *Required*, a list of elements to be repeated.
List can be space or comma separated.
Elements can be in quotes.
For comma separated list add brackets
e.g., `%repList((A,B,C,D),times=5)`.
The list separators are: `<{[( ,;)]}>`.
* `times=` - *Optional*, An integer indicating
the number of repetitions.
By default set to `1`.
* `each=` - *Optional*, A list of integers indicating
the number of repetitions of each element of the list
e.g., for a list `A B C` and the `each=2 4` the result
is `A A B B B B C C`. If the number of integers is less
then the length of the list values are recycled from
the beginning.
By default set to `1`.
* `lenghtOut=` - *Optional*, An integer indicating
after what the number of repetitions process will stop.
By default set to `0` which means "do not stop".
* `sep=` - *Optional*, it is a separator printed between
repeated elements. Mnemonics for *space* is `s`,
for *comma* is `c`, and for semicolon in `q`.
Default value is a single space.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Simple repetition of all elements:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repList((A,B,C,D), times=3);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Simple repetition of each element:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repList(("A",'B',"C",'D'), each=3);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Simple repetition with a separator:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repList(A10;B20;C30, times=3, each=2, sep=Q);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 4.** Recycle elements up to 8 with a comma as a separator:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repList(1 2 3, lenghtOut=8, sep=c);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 5.** Separate number of repetitions for each element:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put [%repList([D][C][B][A], each = 2 3 5 7, sep=] [)];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 6.** "ASCII art" butterflies:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put {>%repList(! $ |, times = 2, each =2 1, sep=<} ... {>)<};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 7.** Data repeating:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data A;
x=17;
data B;
x=42;
data C;
x=303;
run;
data Times2_A10B11C12;
set
%repList(A B C, times = 2, each =10 11 12)
;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%intsList()` macro: <<< <a name="intslist-macro"></a> #######################
The intsList() macro function allows to print a list of

Binary file not shown.

View File

@@ -19,7 +19,7 @@
---
# The macroArray package [ver. 1.0.6] <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:
- `%array()`,
@@ -75,10 +75,10 @@ Package contains:
Required SAS Components:
*Base SAS Software*
*SAS package generated by generatePackage, version 20230905*
*SAS package generated by generatePackage, version 20230904*
The SHA256 hash digest for package macroArray:
`F*4FAAEE7DF2854EA31933AE017A89C1615C7291A66A07CCE345041EB0D587ED4E`
`F*E9C0C58FB36AC40C76A518066B8C6F9942202A9DB2C2D737E95D2BB6E4ECED50`
---
# Content description ############################################################################################
@@ -278,6 +278,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
<,macarray=N>
<,ds=>
<,vars=>
<,q=>
)
~~~~~~~~~~~~~~~~~~~~~~~
@@ -312,8 +313,8 @@ The basic syntax is the following, the `<...>` means optional parameters:
`%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
name is compiled to create convenient envelope for multiple ampersands, e.g.
* `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.
`%array(myArr[*] x1-x3 (4:6), macarray=Y)`
will create `%myArr(J)` macro which will allow to extract "data"
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,
then the minimum and the maximum index is determined
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,
if used by default overwrites use of the `array` parameter, honors `macarray=`
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 #)
values of variable "weight" <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: ####################################################
**EXAMPLE 1.** Basic use-case.
Creating macroarray like in the array statement;
values are used by default;
different types of brackets are allowed;
Creating macroarray like in the array statement.
Values not variables names are used by default.
Different types of brackets are allowed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%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!;
%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.;
%* 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 &=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
%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;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -451,7 +456,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
%* The range handling, warning;
%put *%ll(265)*;
%* The input mode;
%put *before:*%ll(2)*;
%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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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_;
%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)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -599,7 +604,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
%let myTest6 = 16;
%let myTest9 = 19;
%array(myTest, macarray=M)
%array(myTest, macarray=M, q=1)
%do_over(myTest, phrase = %nrstr(%put *&_I_.*%myTest(&_I_.)*;))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Binary file not shown.