The BasePlus package [ver. 1.17]

The BasePlus package [ver. 1.17]

- new macro `%LDSNM()`, which extends functionality of the `%LDSN()` was added.
- documentation updated

hash: 619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD
This commit is contained in:
Bart Jablonski (yabwon)
2022-05-11 23:44:34 +02:00
parent 75029a488f
commit ea866123d9
5 changed files with 220 additions and 48 deletions

View File

@@ -90,7 +90,7 @@ SHA256 digest for macroArray: DF63B0E027827A82038F1C8422787A0BC569BA93104BA1778D
---
- **BasePlus**\[1.16\] adds a bunch of functionalities I am missing in BASE SAS, such as:
- **BasePlus**\[1.17\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```sas
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -108,7 +108,7 @@ format x bool.;
%zipLibrary(sashelp,libOut=work)
```
SHA256 digest for BasePlus: 4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E
SHA256 digest for BasePlus: 619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")

View File

@@ -1,5 +1,8 @@
/* 20220511 */
BasePlus: 619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD
/* 20220509 */
BasePlus:4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E
BasePlus: 4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E
/* 20220508 */
BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D85B0B2DEDE4E9

View File

@@ -46,6 +46,7 @@
* [`%zipLibrary()` macro](#ziplibrary-macro)
* [`%unzipLibrary()` macro](#unziplibrary-macro)
* [`%LDSN()` macro](#ldsn-macro)
* [`%LDsNm()` macro](#ldsnm-macro)
* [`%LVarNm()` macro](#lvarnm-macro)
* [`%LVarNmLab()` macro](#lvarnmlab-macro)
@@ -55,7 +56,7 @@
---
# The BasePlus package [ver. 1.16] <a name="baseplus-package"></a> ###############################################
# The BasePlus package [ver. 1.17] <a name="baseplus-package"></a> ###############################################
The **BasePlus** package implements useful
functions and functionalities I miss in the BASE SAS.
@@ -227,52 +228,53 @@ Package contains:
5. macro functionexists
6. macro getvars
7. macro ldsn
8. macro lvarnm
9. macro lvarnmlab
10. macro qdeduplistx
11. macro qgetvars
12. macro qzipevalf
13. macro raincloudplot
14. macro symdelglobal
15. macro unziplibrary
16. macro zipevalf
17. macro ziplibrary
18. format bool
19. format boolz
20. format ceil
21. format floor
22. format int
23. functions arrfill
24. functions arrfillc
25. functions arrmissfill
26. functions arrmissfillc
27. functions arrmisstoleft
28. functions arrmisstoleftc
29. functions arrmisstoright
30. functions arrmisstorightc
31. functions bracketsc
32. functions bracketsn
33. functions catxfc
34. functions catxfi
35. functions catxfj
36. functions catxfn
37. functions deldataset
38. functions semicolonc
39. functions semicolonn
40. format brackets
41. format semicolon
42. proto qsortincbyprocproto
43. functions frommissingtonumberbs
44. functions fromnumbertomissing
45. functions quicksort4notmiss
46. functions quicksorthash
47. functions quicksorthashsddv
48. functions quicksortlight
8. macro ldsnm
9. macro lvarnm
10. macro lvarnmlab
11. macro qdeduplistx
12. macro qgetvars
13. macro qzipevalf
14. macro raincloudplot
15. macro symdelglobal
16. macro unziplibrary
17. macro zipevalf
18. macro ziplibrary
19. format bool
20. format boolz
21. format ceil
22. format floor
23. format int
24. functions arrfill
25. functions arrfillc
26. functions arrmissfill
27. functions arrmissfillc
28. functions arrmisstoleft
29. functions arrmisstoleftc
30. functions arrmisstoright
31. functions arrmisstorightc
32. functions bracketsc
33. functions bracketsn
34. functions catxfc
35. functions catxfi
36. functions catxfj
37. functions catxfn
38. functions deldataset
39. functions semicolonc
40. functions semicolonn
41. format brackets
42. format semicolon
43. proto qsortincbyprocproto
44. functions frommissingtonumberbs
45. functions fromnumbertomissing
46. functions quicksort4notmiss
47. functions quicksorthash
48. functions quicksorthashsddv
49. functions quicksortlight
*SAS package generated by generatePackage, version 20220420*
The SHA256 hash digest for package BasePlus:
`4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E`
`619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD`
---
# Content description ############################################################################################
@@ -3521,6 +3523,10 @@ run;
The LDSN (Long DataSet Names) macro function
allows to use an "arbitrary" text string to name a dataset.
The LDSN macro has some limitation described below, to overcome them
another macro, with different name: LDSNM (Long DataSet Names Modified)
was created. See its description to learn how to use it.
---
The idea for the macro came from the following story:
@@ -3607,6 +3613,12 @@ The basic syntax is the following, the `<...>` means optional parameters:
)
~~~~~~~~~~~~~~~~~~~~~~~
The text string is concider as *"fully qualified dataset name"*, i.e. macro
assumes it may contain library as prefix and data set options as sufix.
See the `%LDsNm()` macro for comparison.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.**
@@ -3628,6 +3640,163 @@ run;
---
## >>> `%LDSNM()` macro: <<< <a name="ldsnm-macro"></a> #######################
The LDSNM (Long DataSet Names Modified) macro function
allows to use an "arbitrary" text string to name a dataset.
The LDSN macro had some limitation (see its documentation), to overcome them
another `%LDSNM()` (Long DataSet Names Modified) macro was created.
The main idea behind the `%LDSNM()` is the same as for `%LDSN()` - see the description there.
---
The `%LDSNM()` works differently then the `%LDSN()`.
The `%LDSN()` assumed that *both* libname and dataset options *could*
be passed as elements in macro argument, e.g.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data %LDSN( WORK.peanut butter & jelly with a hot-dog in [a box] and s*t*a*r*s (drop = sex) );
set sashelp.class;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `%LDSNM()`, in contrary, assumes that both libname and dataset options are
passed **outside** the macro, i.e.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data WORK.%LDSNM( peanut butter & jelly with a hot-dog in [a box] and s*t*a*r*s ) (drop = sex);
set sashelp.class;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This approach reduces some limitations the LDSN has.
The **additional** feature of the `%LDSNM()` is that when the macro is called
a global macrovariable, which name is the same as hashed dataset name, is created.
The macrovariable value is the text of the argument of the macro. For example
the following macro call:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data %LDSNM(John "x" 'y' dog);
set sashelp.class;
where name = 'John';
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
creates `DSN_BF1F8C4D6495B34A_` macrovariable with value: `JOHN "X" 'Y' DOG`.
The macrovariable is useful when combined with `symget()` function and
the `indsname=` option to get the original text string value back,
like in this example:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data test;
set %LDSNM(John "x" 'y' dog) indsname = i;
indsname = symget(scan(i,-1,"."));
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See examples below for the details.
---
The `%LDSN()` macro executes like a pure macro code.
**Known "Limitations":**
- dataset name _cannot_ contain _unpaired_ round brackets(`(` and `)`)
(but unmatched `[]` and `{}` are allowed)!
- dataset name _cannot_ contain _unpaired_ quotes (`'` and `"`),
text: `a "hot-dog"` is ok, but `John's dog` is not!
**Behaviour:**
- dataset name text is *converted to upcase*
- dataset name text *leading and trailing spaces are ignored*,
e.g. the following will give the same hash digest:
`%ldsn(test)`, `%ldsn( test)`, `%ldsn(test )`.
- macro calls of the form:
`data %LDSN(); run;` or `data %LDSN( ); run;` are resolved
to empty string, so the result is equivalent to `data; run;`
- created macrovariable is _global_ in scope.
### SYNTAX: ###################################################################
The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%LDSNM(
arbitrary text string (in line with limitations)
)
~~~~~~~~~~~~~~~~~~~~~~~
The text string is concider as *"only dataset name"*, i.e. macro does not
assume it contain library as prefix or data set options as sufix.
See the `%LDSN()` macro for comparison.
---
### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data %LDSNM(John "x" 'y' & dog);
set sashelp.class;
where name = 'John';
run;
data %LDSNM(John "x"[ 'y' & dog);
set sashelp.class;
where name = 'John';
run;
data %LDSNM(John "x" 'y'} & dog);
set sashelp.class;
where name = 'John';
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2.**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data work.%LDsNm( peanut butter & jelly, a hot-dog in [a box], and s(*)t(*)a(*)r(*)s!! ) (drop = sex rename=(name=first_name) where = (age in (12,13,14)))
;
set sashelp.class;
run;
data test;
set work.%LDsNm( peanut butter & jelly, a hot-dog in [a box], and s(*)t(*)a(*)r(*)s!! ) indsname=i;
indsname=symget(scan(i,-1,"."));
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3.**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data work.%LDsNm( . );
set sashelp.class;
run;
data %LDsNm( );
set sashelp.class;
run;
data %LDsNm();
set sashelp.class;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%LVarNm()` macro: <<< <a name="lvarnm-macro"></a> #######################
The LVarNm() macro function works like the LDSN() macro function, but for variables.

Binary file not shown.