BasePlus, version 0.8

BasePlus, version 0.8
- New macros added:`%dedupListS()`, `%dedupListC()`, `%dedupListP()`, `%dedupListX()`, and `%QdedupListX()`
This commit is contained in:
yabwon
2020-10-20 21:57:44 +02:00
parent 975a48e242
commit 2730a9438f
5 changed files with 362 additions and 37 deletions

View File

@@ -112,7 +112,7 @@ SHA256 digest for macroArray: 42771AA7CD2A0608E1EE25F104F21CCCC296919910E4BCA7AD
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
- **BasePlus**\[0.7\] adds a bunch of functionalities I am missing in BASE SAS, such as:
- **BasePlus**\[0.8\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -126,7 +126,7 @@ format x bool.;
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
```
SHA256 digest for BasePlus: BDEA8AA6EED9739284ABF8297BEC7EC0F12490D72EF9B685F477E99AFA734B82
SHA256 digest for BasePlus: 9549378E5F81DA4DC421C366DF006D270261852336CE3DCD88FF8E2A759938C8
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/baseplus.md "Documentation for BasePlus")

View File

@@ -80,7 +80,7 @@ SHA256 digest for macroArray: 42771AA7CD2A0608E1EE25F104F21CCCC296919910E4BCA7AD
---
- **BasePlus**\[0.7\] adds a bunch of functionalities I am missing in BASE SAS, such as:
- **BasePlus**\[0.8\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -94,7 +94,7 @@ format x bool.;
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
```
SHA256 digest for BasePlus: BDEA8AA6EED9739284ABF8297BEC7EC0F12490D72EF9B685F477E99AFA734B82
SHA256 digest for BasePlus: 9549378E5F81DA4DC421C366DF006D270261852336CE3DCD88FF8E2A759938C8
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/baseplus.md "Documentation for BasePlus")

View File

@@ -1,3 +1,6 @@
/* 20201020 */
BasePlus: 9549378E5F81DA4DC421C366DF006D270261852336CE3DCD88FF8E2A759938C8
/* 20201018 */
BasePlus: BDEA8AA6EED9739284ABF8297BEC7EC0F12490D72EF9B685F477E99AFA734B82
DFA: E67A0863992722A5F535F56E14EF8D19A55F74FB374447BF11B5ED74029C29CB

View File

@@ -1,4 +1,4 @@
- [The BasePlus package [ver. 0.7]](#baseplus-package)
- [The BasePlus package [ver. 0.8]](#baseplus-package)
- [Content description](#content-description)
* [`%getVars()` macro](#getvars-macro)
* [`%QgetVars()` macro](#qgetvars-macro)
@@ -28,11 +28,17 @@
* [`quickSortHash()` subroutine](#quicksorthash-subroutine)
* [`quickSortHashSDDV()` subroutine](#quicksorthashsddv-subroutine)
* [`quickSortLight()` subroutine](#quicksortlight-subroutine)
* [`%dedupListS()` macro](#deduplists-macro)
* [`%dedupListC()` macro](#deduplistc-macro)
* [`%dedupListP()` macro](#deduplistp-macro)
* [`%dedupListX()` macro](#deduplistx-macro)
* [`%QdedupListX()` macro](#qdeduplistx-macro)
* [License](#license)
---
# The BasePlus package [ver. 0.7] <a name="baseplus-package"></a> ###############################################
# The BasePlus package [ver. 0.8] <a name="baseplus-package"></a> ###############################################
The **BasePlus** package implements useful
functions and functionalities I miss in the BASE SAS.
@@ -40,6 +46,7 @@ functions and functionalities I miss in the BASE SAS.
It is inspired by various people, e.g.
- at the SAS-L discussion list
- at the communities.sas.com (SASware Ballot Ideas)
- at the Office...
- etc.
Kudos to all who inspired me to generate this package:
@@ -149,44 +156,53 @@ Kudos to all who inspired me to generate this package:
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### Content ###################################################################
**Example 7**: Deduplicate values from a space separated list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4 5 6 1 2 3 1 2 3 4 5 6;
%put *%dedupListS(&list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
Package contains:
1. macro getvars
2. macro qgetvars
3. macro symdelglobal
4. format bool
5. format boolz
6. format ceil
7. format floor
8. format int
9. function arrfill
10. function arrfillc
11. function arrmissfill
12. function arrmissfillc
13. function arrmisstoleft
14. function arrmisstoleftc
15. function arrmisstoright
16. function arrmisstorightc
17. function catxfc
18. function catxfi
19. function catxfj
20. function catxfn
21. function deldataset
22. proto qsortincbyprocproto
23. function frommissingtonumberbs
24. function fromnumbertomissing
25. function quicksort4notmiss
26. function quicksorthash
27. function quicksorthashsddv
28. function quicksortlight
1. macro deduplistc
2. macro deduplistp
3. macro deduplists
4. macro deduplistx
5. macro getvars
6. macro qdeduplistx
7. macro qgetvars
8. macro symdelglobal
9. format bool
10. format boolz
11. format ceil
12. format floor
13. format int
14. functions arrfill
15. functions arrfillc
16. functions arrmissfill
17. functions arrmissfillc
18. functions arrmisstoleft
19. functions arrmisstoleftc
20. functions arrmisstoright
21. functions arrmisstorightc
22. functions catxfc
23. functions catxfi
24. functions catxfj
25. functions catxfn
26. functions deldataset
27. proto qsortincbyprocproto
28. functions frommissingtonumberbs
29. functions fromnumbertomissing
30. functions quicksort4notmiss
31. functions quicksorthash
32. functions quicksorthashsddv
33. functions quicksortlight
*SAS package generated by generatePackage, version 20201001*
*SAS package generated by generatePackage, version 20201018*
The SHA256 hash digest for package BasePlus:
`BDEA8AA6EED9739284ABF8297BEC7EC0F12490D72EF9B685F477E99AFA734B82`
`9549378E5F81DA4DC421C366DF006D270261852336CE3DCD88FF8E2A759938C8`
---
# Content description ############################################################################################
@@ -2131,6 +2147,312 @@ call quickSortLight(A)
---
## >>> `%dedupListS()` macro: <<< <a name="deduplists-macro"></a> #######################
The `%dedupListS()` macro deletes duplicated values from
a *SPACE separated* list of values. List, including separators,
can be no longer than a value carried by a single macrovariable.
Returned value is *unquoted*.
The `%dedupListS()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%dedupListS(
list of space separated values
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - A list of *space separated* values.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Basic use-case one.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListS(a b c b c)*;
%put *%dedupListS(a b,c b,c)*;
%put *%dedupListS(%str(a b c b c))*;
%put *%dedupListS(%str(a) %str(b) %str(c) b c)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Macro variable as an argument.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4 5 6 1 2 3 1 2 3 4 5 6;
%put *%dedupListS(&list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%dedupListC()` macro: <<< <a name="deduplistc-macro"></a> #######################
The `%dedupListC()` macro deletes duplicated values from
a *COMMA separated* list of values. List, including separators,
can be no longer than a value carried by a single macrovariable.
Returned value is *unquoted*. Leading and trailing spaces are ignored.
The `%dedupListC()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%dedupListC(
list,of,comma,separated,values
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - A list of *comma separated* values.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Basic use-case one.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListC(a,b,c,b,c)*;
%put *%dedupListC(a,b c,b c)*;
%put *%dedupListC(%str(a,b,c,b,c))*;
%put *%dedupListC(%str(a),%str(b),%str(c),b,c)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Leading and trailing spaces are ignored.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListC( a , b b , c , b b, c )*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Macro variable as an argument.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4, 5, 6, 1, 2, 3, 1, 2, 3, 4, 5, 6;
%put *%dedupListC(&list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%dedupListP()` macro: <<< <a name="deduplistp-macro"></a> #######################
The `%dedupListP()` macro deletes duplicated values from
a *PIPE(`|`) separated* list of values. List, including separators,
can be no longer than a value carried by a single macrovariable.
Returned value is *unquoted*. Leading and trailing spaces are ignored.
The `%dedupListP()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%dedupListP(
list|of|pipe|separated|values
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - A list of *pipe separated* values.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Basic use-case one.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListP(a|b|c|b|c)*;
%put *%dedupListP(a|b c|b c)*;
%put *%dedupListP(%str(a|b|c|b|c))*;
%put *%dedupListP(%str(a)|%str(b)|%str(c)|b|c)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Leading and trailing spaces are ignored.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListP( a | b b | c | b b| c )*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Macro variable as an argument.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4|5|6|1|2|3|1|2|3|4|5|6;
%put *%dedupListP(&list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%dedupListX()` macro: <<< <a name="deduplistx-macro"></a> #######################
The `%dedupListX()` macro deletes duplicated values from
a *X separated* list of values, where the `X` represents
a *single character* separator. List, including separators,
can be no longer than a value carried by a single macrovariable.
**Caution.** The value of `X` *has to be* in **the first** byte of the list,
just after the opening bracket, i.e. `(X...)`.
Returned value is *unquoted*. Leading and trailing spaces are ignored.
The `%dedupListX()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%dedupListX(
XlistXofXxXseparatedXvalues
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - A list of *X separated* values.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Basic use-case one.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListX(|a|b|c|b|c)*;
%put *%dedupListX( a b c b c)*;
%put *%dedupListX(,a,b,c,b,c)*;
%put *%dedupListX(XaXbXcXbXc)*;
%put *%dedupListX(/a/b/c/b/c)*;
data _null_;
x = "%dedupListX(%str(;a;b;c;b;c))";
put x=;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Leading and trailing spaces are ignored.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%dedupListX(| a | b.b | c | b.b| c )*;
%put *%dedupListX(. a . b b . c . b b. c )*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Macro variable as an argument.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4$5.5$6$1$2$3$1$2$3$4$5.5$6;
%put *%dedupListX($&list.)*;
%let list = 4$ 5.5$ 6$ 1$ 2$ 3$ 1$ 2$ 3$ 4$ 5.5$ 6$;
%put *%dedupListX( &list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%QdedupListX()` macro: <<< <a name="qdeduplistx-macro"></a> #######################
The `%QdedupListX()` macro deletes duplicated values from
a *X separated* list of values, where the `X` represents
a *single character* separator. List, including separators,
can be no longer than a value carried by a single macrovariable.
**Caution.** The value of `X` *has to be* in **the first** byte of the list,
just after the opening bracket, i.e. `(X...)`.
Returned value is **quoted** with `%superq()`. Leading and trailing spaces are ignored.
The `%QdedupListX()` macro executes like a pure macro code.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%QdedupListX(
XlistXofXxXseparatedXvalues
)
~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `list` - A list of *X separated* values.
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** Basic use-case one.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%QdedupListX(|a|b|c|b|c)*;
%put *%QdedupListX( a b c b c)*;
%put *%QdedupListX(,a,b,c,b,c)*;
%put *%QdedupListX(XaXbXcXbXc)*;
%put *%QdedupListX(/a/b/c/b/c)*;
%put *%QdedupListX(%str(;a;b;c;b;c))*;
%put *%QdedupListX(%nrstr(&a&b&c&b&c))*;
%put *%QdedupListX(%nrstr(%a%b%c%b%c))*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.** Leading and trailing spaces are ignored.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%put *%QdedupListX(| a | b.b | c | b.b| c )*;
%put *%QdedupListX(. a . b b . c . b b. c )*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.** Macro variable as an argument.
Delete duplicated values from a list.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let list = 4$5.5$6$1$2$3$1$2$3$4$5.5$6;
%put *%QdedupListX($&list.)*;
%let list = 4$ 5.5$ 6$ 1$ 2$ 3$ 1$ 2$ 3$ 4$ 5.5$ 6$;
%put *%QdedupListX( &list.)*;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## License ####################################################################
Copyright (c) 2020 Bartosz Jablonski

Binary file not shown.