Compare commits

..

1 Commits

Author SHA1 Message Date
Bart Jablonski (yabwon)
ea866123d9 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
2022-05-11 23:44:34 +02:00
5 changed files with 220 additions and 48 deletions

View File

@@ -146,7 +146,7 @@ SHA256 digest for macroArray: DF63B0E027827A82038F1C8422787A0BC569BA93104BA1778D
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/macroarray.md "Documentation for macroArray") [Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/macroarray.md "Documentation for macroArray")
- **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 ```sas
call arrMissToRight(myArray); call arrMissToRight(myArray);
call arrFillMiss(17, myArray); call arrFillMiss(17, myArray);
@@ -164,7 +164,7 @@ format x bool.;
%zipLibrary(sashelp,libOut=work) %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") [Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")

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 ```sas
call arrMissToRight(myArray); call arrMissToRight(myArray);
call arrFillMiss(17, myArray); call arrFillMiss(17, myArray);
@@ -108,7 +108,7 @@ format x bool.;
%zipLibrary(sashelp,libOut=work) %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") [Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")

View File

@@ -1,3 +1,6 @@
/* 20220511 */
BasePlus: 619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD
/* 20220509 */ /* 20220509 */
BasePlus: 4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E BasePlus: 4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E

View File

@@ -46,6 +46,7 @@
* [`%zipLibrary()` macro](#ziplibrary-macro) * [`%zipLibrary()` macro](#ziplibrary-macro)
* [`%unzipLibrary()` macro](#unziplibrary-macro) * [`%unzipLibrary()` macro](#unziplibrary-macro)
* [`%LDSN()` macro](#ldsn-macro) * [`%LDSN()` macro](#ldsn-macro)
* [`%LDsNm()` macro](#ldsnm-macro)
* [`%LVarNm()` macro](#lvarnm-macro) * [`%LVarNm()` macro](#lvarnm-macro)
* [`%LVarNmLab()` macro](#lvarnmlab-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 The **BasePlus** package implements useful
functions and functionalities I miss in the BASE SAS. functions and functionalities I miss in the BASE SAS.
@@ -227,52 +228,53 @@ Package contains:
5. macro functionexists 5. macro functionexists
6. macro getvars 6. macro getvars
7. macro ldsn 7. macro ldsn
8. macro lvarnm 8. macro ldsnm
9. macro lvarnmlab 9. macro lvarnm
10. macro qdeduplistx 10. macro lvarnmlab
11. macro qgetvars 11. macro qdeduplistx
12. macro qzipevalf 12. macro qgetvars
13. macro raincloudplot 13. macro qzipevalf
14. macro symdelglobal 14. macro raincloudplot
15. macro unziplibrary 15. macro symdelglobal
16. macro zipevalf 16. macro unziplibrary
17. macro ziplibrary 17. macro zipevalf
18. format bool 18. macro ziplibrary
19. format boolz 19. format bool
20. format ceil 20. format boolz
21. format floor 21. format ceil
22. format int 22. format floor
23. functions arrfill 23. format int
24. functions arrfillc 24. functions arrfill
25. functions arrmissfill 25. functions arrfillc
26. functions arrmissfillc 26. functions arrmissfill
27. functions arrmisstoleft 27. functions arrmissfillc
28. functions arrmisstoleftc 28. functions arrmisstoleft
29. functions arrmisstoright 29. functions arrmisstoleftc
30. functions arrmisstorightc 30. functions arrmisstoright
31. functions bracketsc 31. functions arrmisstorightc
32. functions bracketsn 32. functions bracketsc
33. functions catxfc 33. functions bracketsn
34. functions catxfi 34. functions catxfc
35. functions catxfj 35. functions catxfi
36. functions catxfn 36. functions catxfj
37. functions deldataset 37. functions catxfn
38. functions semicolonc 38. functions deldataset
39. functions semicolonn 39. functions semicolonc
40. format brackets 40. functions semicolonn
41. format semicolon 41. format brackets
42. proto qsortincbyprocproto 42. format semicolon
43. functions frommissingtonumberbs 43. proto qsortincbyprocproto
44. functions fromnumbertomissing 44. functions frommissingtonumberbs
45. functions quicksort4notmiss 45. functions fromnumbertomissing
46. functions quicksorthash 46. functions quicksort4notmiss
47. functions quicksorthashsddv 47. functions quicksorthash
48. functions quicksortlight 48. functions quicksorthashsddv
49. functions quicksortlight
*SAS package generated by generatePackage, version 20220420* *SAS package generated by generatePackage, version 20220420*
The SHA256 hash digest for package BasePlus: The SHA256 hash digest for package BasePlus:
`4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E` `619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD`
--- ---
# Content description ############################################################################################ # Content description ############################################################################################
@@ -3521,6 +3523,10 @@ run;
The LDSN (Long DataSet Names) macro function The LDSN (Long DataSet Names) macro function
allows to use an "arbitrary" text string to name a dataset. 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: 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: #################################################### ### EXAMPLES AND USECASES: ####################################################
**EXAMPLE 1.** **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> ####################### ## >>> `%LVarNm()` macro: <<< <a name="lvarnm-macro"></a> #######################
The LVarNm() macro function works like the LDSN() macro function, but for variables. The LVarNm() macro function works like the LDSN() macro function, but for variables.

Binary file not shown.