6 Commits

Author SHA1 Message Date
Bart Jablonski
29e37b4b79 Merge pull request #13 from SASPAC/dev
The BasePlus package [ver. 1.23.0]
2023-04-19 16:49:02 +02:00
Bart Jablonski
5d914da02d The BasePlus package [ver. 1.23.0]
The BasePlus package [ver. 1.23.0]

Three new utility macros for the BasePlus:
- `%intsList()` - prints a space separated list of integers,
- `%splitDSIntoBlocks()` - splits dataset into block of given size (and one[the last] possibly smaller)
- `%splitDSIntoParts()` - splits dataset into given number of parts (of approximately same size)

Macros `splitDSIntoBlocks` and `splitDSIntoParts` supports *BASE* and *SPDE* engines.

Documentation updated.
2023-04-19 16:39:09 +02:00
SASPAC - SAS Packages Archive
a2d9c6ce9f Merge pull request #12 from SASPAC/dev
The BasePlus package [ver. 1.20.0]
2023-04-17 15:00:11 +02:00
Bart Jablonski
4fb506753c The BasePlus package [ver. 1.20.0]
The BasePlus package [ver. 1.20.0]

- New utility macro `%repeatTxt()` added.
- Documentation updated.
2023-04-17 14:57:48 +02:00
SASPAC - SAS Packages Archive
ff0a008142 Merge pull request #11 from SASPAC/dev
The BasePlus package [ver. 1.19.1]
2023-04-11 18:44:17 +02:00
Bart Jablonski
505f501892 The BasePlus package [ver. 1.19.1]
The BasePlus package [ver. 1.19.1]

Package regenerated with the latest version of the SAS Packages Framework (20230411).
2023-04-11 18:38:20 +02:00
6 changed files with 380 additions and 55 deletions

View File

@@ -25,10 +25,18 @@ format x bool.;
%bpPIPE(ls -la ~/) %bpPIPE(ls -la ~/)
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result) %dirsAndFiles(C:\SAS_WORK\,ODS=work.result)
%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$);
%put %intsList(42);
%splitDSIntoBlocks(5, sashelp.class, classBlock)
%splitDSIntoParts(7, sashelp.cars, carsPart)
``` ```
and more. and more.
SHA256 digest for the latest version of `BasePlus`: F*AD0B78F94A6FD1C394999CBBC8DD16017FB06DFC3FA1F51AC17B43AC8F517432 SHA256 digest for the latest version of `BasePlus`: F*625E56B017C4AA8D436959C0A03C8503773A9A3823D43FA9E0326276E52DA6F2
[**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus") [**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus")

View File

@@ -51,12 +51,16 @@
* [`%LVarNmLab()` macro](#lvarnmlab-macro) * [`%LVarNmLab()` macro](#lvarnmlab-macro)
* [`%bpPIPE()` macro](#bppipe-macro) * [`%bpPIPE()` macro](#bppipe-macro)
* [`%dirsAndFiles()` macro](#dirsandfiles-macro) * [`%dirsAndFiles()` macro](#dirsandfiles-macro)
* [`%repeatTxt()` macro](#repeattxt-macro)
* [`%intsList()` macro](#intslist-macro)
* [`%splitDSIntoBlocks()` macro](#splitdsintoblocks-macro)
* [`%splitDSIntoParts()` macro](#splitdsintoparts-macro)
* [License](#license) * [License](#license)
--- ---
# The BasePlus package [ver. 1.19.0] <a name="baseplus-package"></a> ############################################### # The BasePlus package [ver. 1.20.0] <a name="baseplus-package"></a> ###############################################
The **BasePlus** package implements useful The **BasePlus** package implements useful
functions and functionalities I miss in the BASE SAS. functions and functionalities I miss in the BASE SAS.
@@ -231,69 +235,80 @@ run;
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result) %dirsAndFiles(C:\SAS_WORK\,ODS=work.result)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 14** Text repetition:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- ---
Package contains: Package contains:
1. macro bppipe 1. macro bppipe
2. macro deduplistc 2. macro deduplistc
3. macro deduplistp 3. macro deduplistp
4. macro deduplists 4. macro deduplists
5. macro deduplistx 5. macro deduplistx
6. macro dirsandfiles 6. macro dirsandfiles
7. macro functionexists 7. macro functionexists
8. macro getvars 8. macro getvars
9. macro ldsn 9. macro intslist
10. macro ldsnm 10. macro ldsn
11. macro lvarnm 11. macro ldsnm
12. macro lvarnmlab 12. macro lvarnm
13. macro qdeduplistx 13. macro lvarnmlab
14. macro qgetvars 14. macro qdeduplistx
15. macro qzipevalf 15. macro qgetvars
16. macro raincloudplot 16. macro qzipevalf
17. macro symdelglobal 17. macro raincloudplot
18. macro unziplibrary 18. macro repeattxt
19. macro zipevalf 19. macro splitdsintoblocks
20. macro ziplibrary 20. macro splitdsintoparts
21. format bool 21. macro symdelglobal
22. format boolz 22. macro unziplibrary
23. format ceil 23. macro zipevalf
24. format floor 24. macro ziplibrary
25. format int 25. format bool
26. functions arrfill 26. format boolz
27. functions arrfillc 27. format ceil
28. functions arrmissfill 28. format floor
29. functions arrmissfillc 29. format int
30. functions arrmisstoleft 30. functions arrfill
31. functions arrmisstoleftc 31. functions arrfillc
32. functions arrmisstoright 32. functions arrmissfill
33. functions arrmisstorightc 33. functions arrmissfillc
34. functions bracketsc 34. functions arrmisstoleft
35. functions bracketsn 35. functions arrmisstoleftc
36. functions catxfc 36. functions arrmisstoright
37. functions catxfi 37. functions arrmisstorightc
38. functions catxfj 38. functions bracketsc
39. functions catxfn 39. functions bracketsn
40. functions deldataset 40. functions catxfc
41. functions semicolonc 41. functions catxfi
42. functions semicolonn 42. functions catxfj
43. format brackets 43. functions catxfn
44. format semicolon 44. functions deldataset
45. proto qsortincbyprocproto 45. functions semicolonc
46. functions frommissingtonumberbs 46. functions semicolonn
47. functions fromnumbertomissing 47. format brackets
48. functions quicksort4notmiss 48. format semicolon
49. functions quicksorthash 49. proto qsortincbyprocproto
50. functions quicksorthashsddv 50. functions frommissingtonumberbs
51. functions quicksortlight 51. functions fromnumbertomissing
52. functions quicksort4notmiss
53. functions quicksorthash
54. functions quicksorthashsddv
55. functions quicksortlight
Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it
or look for the baseplus_AdditionalContent directory in the Packages fileref or look for the baseplus_AdditionalContent directory in the Packages fileref
localization (only if additional content was deployed during the installation process). localization (only if additional content was deployed during the installation process).
* SAS package generated by generatePackage, version 20230207 * * SAS package generated by generatePackage, version 20230411 *
The SHA256 hash digest for package BasePlus: The SHA256 hash digest for package BasePlus:
`F*AD0B78F94A6FD1C394999CBBC8DD16017FB06DFC3FA1F51AC17B43AC8F517432` `F*625E56B017C4AA8D436959C0A03C8503773A9A3823D43FA9E0326276E52DA6F2`
--- ---
# Content description ############################################################################################ # Content description ############################################################################################
@@ -4123,10 +4138,312 @@ The basic syntax is the following, the `<...>` means optional parameters:
%dirsAndFiles(%sysfunc(pathname(WORK))/noSuchDir,ODS=work.result12,details=1) %dirsAndFiles(%sysfunc(pathname(WORK))/noSuchDir,ODS=work.result12,details=1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%repeatTxt()` macro: <<< <a name="repeattxt-macro"></a> #######################
The repeatTxt() macro function allows to repeat `n`
times a `text` string separated by string `s=`.
The repeatTxt() returns unquoted value [by %unquote()].
See examples below for the details.
The `%repeatTxt()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%repeatTxt(
text
<,n>
<,s=>
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `text` - *Required*, a text to be repeated.
2. `n` - *Required/Optional*, the number of repetitions.
If missing then set to `1`;
* `s = %str( )` - *Optional*, it is a separator between
repeated elements. Default value is space.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Simple repetition of dataset name:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options mprint;
data work.test5;
set
%repeatTxt(sashelp.cars, 5)
;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Simple repetition of data step:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options mprint;
%repeatTxt(data _null_; set sashelp.cars; run;, 3)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** "Nice" output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 4.** Macroquote a text with commas:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%repeatTxt(
%str(proc sql; create table wh as select weight,height from sashelp.class; quit;)
,3
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 5.** Empty `n` repeats `text` one time:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options mprint;
data work.test1;
set
%repeatTxt(sashelp.cars)
;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 6.** Dynamic "formatting":
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%macro printWork();
%let work=%sysfunc(pathname(work));
%put +%repeatTxt(~,%length(&work.)+5,s=)+;
%put {&=work.};
%put +%repeatTxt(~,%length(&work.)+5,s=)+;
%mend printWork;
%printWork()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%intsList()` macro: <<< <a name="intslist-macro"></a> #######################
The intsList() macro function allows to print a list of
integers starting from `start` up to `end` incremented by `by`
and separated by `sep=`.
If `start`, `end` or `by` are non-integers the are converted to integers.
See examples below for the details.
The `%intsList()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%intsList(
start
<,end>
<,by>
<,sep=>
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `start` - *Required*, the first value of the list.
If `end` is missing then the list is generated
from 1 to `start` by 1.
2. `end` - *Required/Optional*, the last value of the list.
3. `by` - *Required/Optional*, the increment of the list.
If missing then set to `1`.
*Cannot* be equal to `0`.
* `s = %str( )` - *Optional*, it is a separator between
elements of the list. Default value is space.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Simple list of integers from 1 to 10 by 1:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %intsList(10);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Ten copies of `sashelp.class` in `test11` to `test20`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data
%zipEvalf(test, %intsList(11,20))
;
set sashelp.class;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Non-integers are converted to integers, the list is `1 3 5`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %intsList(1.1,5.2,2.3);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 4.** A list with a separator:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put %intsList(1,5,2,sep=+);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%splitDSIntoBlocks()` macro: <<< <a name="splitdsintoblocks-macro"></a> #######################
The splitDSIntoBlocks() macro allows to split the `set` dataset into blocks
of size `blockSize` in datasets: `prefix1` to `prefixN`.
The last dataset may have less observations then the `blockSize`.
Macro covers `BASE` engine (`v9`, `v8`, `v7`, `v6`) and `SPDE` engine datasets.
See examples below for the details.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%splitDSIntoBlocks(
blockSize
<,set>
<,prefix>
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `blockSize` - *Required*, the size of the block of data,
in other words number of observations in
one block of split data.
Block size must be positive integer.
2. `set` - *Required/Optional*, the name of the dataset to split.
If empty then `&syslast.` is used.
3. `prefix` - *Required/Optional*, the name-prefix for new datasets.
If missing then set to `part`.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Split `sashelp.class` into 5 elements datasets ABC1 to ABC4:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%splitDSIntoBlocks(5,sashelp.class,ABC)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** By default splits the `_last_` dataset into `part1` to `partN` datasets:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data lastData;
set sashelp.cars;
run;
%splitDSIntoBlocks(123)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Works with `SPDE` engine too:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options dlcreatedir;
libname test "%sysfunc(pathname(work))/testSPDE";
libname test;
libname test SPDE "%sysfunc(pathname(work))/testSPDE";
data test.test;
set sashelp.cars;
run;
%splitDSIntoBlocks(100,test.test,work.spde)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%splitDSIntoParts()` macro: <<< <a name="splitdsintoparts-macro"></a> #######################
The splitDSIntoParts() macro allows to split the `set` dataset into `parts` parts
of approximately `NOBS/parts` size in datasets: `prefix1` to `prefixN`.
The splitDSIntoParts() macro internally runs the splitDSIntoBlocks() macro.
Macro covers `BASE` engine (`v9`, `v8`, `v7`, `v6`) and `SPDE` engine datasets.
See examples below for the details.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%splitDSIntoParts(
parts
<,set>
<,prefix>
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `parts` - *Required*, the number of parts to split data into.
Number of parts must be positive integer.
2. `set` - *Required/Optional*, the name of the dataset to split.
If empty then `&syslast.` is used.
3. `prefix` - *Required/Optional*, the name-prefix for new datasets.
If missing then set to `part`.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Split `sashelp.cars` into 7 parts: datasets carsInParts1 to carsInParts7:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%splitDSIntoParts(7,sashelp.cars, carsInParts)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** By default splits the `_last_` dataset into `part1` to `part3` datasets:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data lastData;
set sashelp.cars;
run;
%splitDSIntoBlocks(3)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Works with `SPDE` engine too:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
options dlcreatedir;
libname test "%sysfunc(pathname(work))/testSPDE";
libname test;
libname test SPDE "%sysfunc(pathname(work))/testSPDE";
data test.test;
set sashelp.cars;
run;
%splitDSIntoParts(3,test.test,work.spde)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
---
--- ---

Binary file not shown.

BIN
hist/1.19.1/baseplus.zip Normal file

Binary file not shown.

BIN
hist/1.20.0/baseplus.zip Normal file

Binary file not shown.

BIN
hist/1.23.0/baseplus.zip Normal file

Binary file not shown.