mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2025-12-11 03:04:35 +00:00
The BasePlus package [ver. 1.30.0]
The BasePlus package [ver. 1.30.0] - new macro `%repList()` added - doc. updated SHA256 digest: `F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F`
This commit is contained in:
@@ -86,7 +86,7 @@ SHA256 digest for macroArray: F*6A22A01868F4203862B3685F543D723C7DB8E9AB3C1A6357
|
||||
|
||||
---
|
||||
|
||||
- **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")
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/* 20230919 */
|
||||
BasePlus: F*B91771D45C781B6806DBB44A3B491A0784D7698B9F3BBBE1A86EE5594834315F
|
||||
|
||||
/* 20230906 */
|
||||
macroArray: F*6A22A01868F4203862B3685F543D723C7DB8E9AB3C1A6357D2BFA030971B0D3C
|
||||
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user