mirror of
https://github.com/SASPAC/baseplus.git
synced 2025-12-10 14:34:35 +00:00
The BasePlus package [ver. 1.19.0]
The BasePlus package [ver. 1.19.0] New macro: The `%dirsAndFiles()` macro allows to extract info about all files and subdirectories of a given `root` directory. The macro is based on Kurt Bremser's "*Talking to Your Host*" article presented at WUSS 2022 conference.
This commit is contained in:
@@ -23,10 +23,12 @@ format x bool.;
|
||||
%zipLibrary(sashelp,libOut=work)
|
||||
|
||||
%bpPIPE(ls -la ~/)
|
||||
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result)
|
||||
```
|
||||
and more.
|
||||
|
||||
SHA256 digest for the latest version of `BasePlus`: A6F1977DC4EC22A39DDC7BCE68CF562AF54351A3D385D488EC3067B5A7C0F3CB
|
||||
SHA256 digest for the latest version of `BasePlus`: F*AD0B78F94A6FD1C394999CBBC8DD16017FB06DFC3FA1F51AC17B43AC8F517432
|
||||
|
||||
[**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus")
|
||||
|
||||
|
||||
254
baseplus.md
254
baseplus.md
@@ -50,13 +50,13 @@
|
||||
* [`%LVarNm()` macro](#lvarnm-macro)
|
||||
* [`%LVarNmLab()` macro](#lvarnmlab-macro)
|
||||
* [`%bpPIPE()` macro](#bppipe-macro)
|
||||
|
||||
* [`%dirsAndFiles()` macro](#dirsandfiles-macro)
|
||||
|
||||
* [License](#license)
|
||||
|
||||
---
|
||||
|
||||
# The BasePlus package [ver. 1.18.4] <a name="baseplus-package"></a> ###############################################
|
||||
# The BasePlus package [ver. 1.19.0] <a name="baseplus-package"></a> ###############################################
|
||||
|
||||
The **BasePlus** package implements useful
|
||||
functions and functionalities I miss in the BASE SAS.
|
||||
@@ -75,7 +75,8 @@ Kudos to all who inspired me to generate this package:
|
||||
*Allan Bowe*,
|
||||
*Anamaria Calai*,
|
||||
*Michal Ludwicki*,
|
||||
*Quentin McMullen*.
|
||||
*Quentin McMullen*,
|
||||
*Kurt Bremser*.
|
||||
|
||||
Recording from the SAS Explore 2022 conference: [A BasePlus Package for SAS](https://communities.sas.com/t5/SAS-Explore-Presentations/A-BasePlus-Package-for-SAS/ta-p/838246 "A BasePlus Package for SAS") (September 27th-29th, 2022).
|
||||
|
||||
@@ -225,6 +226,11 @@ run;
|
||||
%bpPIPE(ls -la ~/)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**EXAMPLE 13** Get list of all files and directories from `C:\SAS_WORK\`:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
---
|
||||
|
||||
Package contains:
|
||||
@@ -233,56 +239,61 @@ Package contains:
|
||||
3. macro deduplistp
|
||||
4. macro deduplists
|
||||
5. macro deduplistx
|
||||
6. macro functionexists
|
||||
7. macro getvars
|
||||
8. macro ldsn
|
||||
9. macro ldsnm
|
||||
10. macro lvarnm
|
||||
11. macro lvarnmlab
|
||||
12. macro qdeduplistx
|
||||
13. macro qgetvars
|
||||
14. macro qzipevalf
|
||||
15. macro raincloudplot
|
||||
16. macro symdelglobal
|
||||
17. macro unziplibrary
|
||||
18. macro zipevalf
|
||||
19. macro ziplibrary
|
||||
20. format bool
|
||||
21. format boolz
|
||||
22. format ceil
|
||||
23. format floor
|
||||
24. format int
|
||||
25. functions arrfill
|
||||
26. functions arrfillc
|
||||
27. functions arrmissfill
|
||||
28. functions arrmissfillc
|
||||
29. functions arrmisstoleft
|
||||
30. functions arrmisstoleftc
|
||||
31. functions arrmisstoright
|
||||
32. functions arrmisstorightc
|
||||
33. functions bracketsc
|
||||
34. functions bracketsn
|
||||
35. functions catxfc
|
||||
36. functions catxfi
|
||||
37. functions catxfj
|
||||
38. functions catxfn
|
||||
39. functions deldataset
|
||||
40. functions semicolonc
|
||||
41. functions semicolonn
|
||||
42. format brackets
|
||||
43. format semicolon
|
||||
44. proto qsortincbyprocproto
|
||||
45. functions frommissingtonumberbs
|
||||
46. functions fromnumbertomissing
|
||||
47. functions quicksort4notmiss
|
||||
48. functions quicksorthash
|
||||
49. functions quicksorthashsddv
|
||||
50. functions quicksortlight
|
||||
6. macro dirsandfiles
|
||||
7. macro functionexists
|
||||
8. macro getvars
|
||||
9. macro ldsn
|
||||
10. macro ldsnm
|
||||
11. macro lvarnm
|
||||
12. macro lvarnmlab
|
||||
13. macro qdeduplistx
|
||||
14. macro qgetvars
|
||||
15. macro qzipevalf
|
||||
16. macro raincloudplot
|
||||
17. macro symdelglobal
|
||||
18. macro unziplibrary
|
||||
19. macro zipevalf
|
||||
20. macro ziplibrary
|
||||
21. format bool
|
||||
22. format boolz
|
||||
23. format ceil
|
||||
24. format floor
|
||||
25. format int
|
||||
26. functions arrfill
|
||||
27. functions arrfillc
|
||||
28. functions arrmissfill
|
||||
29. functions arrmissfillc
|
||||
30. functions arrmisstoleft
|
||||
31. functions arrmisstoleftc
|
||||
32. functions arrmisstoright
|
||||
33. functions arrmisstorightc
|
||||
34. functions bracketsc
|
||||
35. functions bracketsn
|
||||
36. functions catxfc
|
||||
37. functions catxfi
|
||||
38. functions catxfj
|
||||
39. functions catxfn
|
||||
40. functions deldataset
|
||||
41. functions semicolonc
|
||||
42. functions semicolonn
|
||||
43. format brackets
|
||||
44. format semicolon
|
||||
45. proto qsortincbyprocproto
|
||||
46. functions frommissingtonumberbs
|
||||
47. functions fromnumbertomissing
|
||||
48. functions quicksort4notmiss
|
||||
49. functions quicksorthash
|
||||
50. functions quicksorthashsddv
|
||||
51. functions quicksortlight
|
||||
|
||||
*SAS package generated by generatePackage, version 20221215*
|
||||
Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it
|
||||
or look for the baseplus_AdditionalContent directory in the Packages fileref
|
||||
localization (only if additional content was deployed during the installation process).
|
||||
|
||||
* SAS package generated by generatePackage, version 20230207 *
|
||||
|
||||
The SHA256 hash digest for package BasePlus:
|
||||
`A6F1977DC4EC22A39DDC7BCE68CF562AF54351A3D385D488EC3067B5A7C0F3CB`
|
||||
`F*AD0B78F94A6FD1C394999CBBC8DD16017FB06DFC3FA1F51AC17B43AC8F517432`
|
||||
|
||||
---
|
||||
# Content description ############################################################################################
|
||||
@@ -3975,6 +3986,149 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
||||
|
||||
---
|
||||
|
||||
## >>> `%dirsAndFiles()` macro: <<< <a name="dirsandfiles-macro"></a> #######################
|
||||
|
||||
The `%dirsAndFiles()` macro allows to extract info about all files
|
||||
and subdirectories of a given `root` directory.
|
||||
|
||||
The extracted info may be just a list of files and subdirectories or, if
|
||||
the `details=` parameter is set to 1, additional operating system information
|
||||
is extracted (information is OSS dependent and gives different results for Linux
|
||||
and for Windows)
|
||||
|
||||
The extracted info can be narrowed down to files (`keepFiles=1`) or to
|
||||
directories (`keepDirs=1`) if need be.
|
||||
|
||||
The extracted info can be presented in wide or long format (`longFormat=1`).
|
||||
|
||||
The extracted info for files can be narrowed down to only files with particular
|
||||
extension, for example: `fileExt=sas7bdat`.
|
||||
|
||||
The extracted info can be narrowed down maximal path depth
|
||||
by setting up the `maxDepth=` parameter.
|
||||
|
||||
See examples below for the details.
|
||||
|
||||
### REFERENCES: ###################################################################
|
||||
|
||||
The macro is based on Kurt Bremser's "*Talking to Your Host*" article
|
||||
presented at WUSS 2022 conference.
|
||||
|
||||
The article is available [here](https://communities.sas.com/t5/SAS-User-Groups-Library/WUSS-Presentation-Talking-to-Your-Host/ta-p/838344)
|
||||
and also as an additional content of this package.
|
||||
The paper was awarded the "Best Paper Award - Programming".
|
||||
|
||||
### SYNTAX: ###################################################################
|
||||
|
||||
The basic syntax is the following, the `<...>` means optional parameters:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(
|
||||
root
|
||||
<,ODS=>
|
||||
<,details=>
|
||||
<,keepDirs=>
|
||||
<,keepFiles=>
|
||||
<,longFormat=>
|
||||
<,fileExt=>
|
||||
<,maxDepth=>
|
||||
)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Arguments description**:
|
||||
|
||||
1. `root` - *Required*, path to be searched
|
||||
for information.
|
||||
|
||||
* `ODS=work.dirsAndFilesInfo` - *Optional*, output data set,
|
||||
name of a dataset to store information.
|
||||
|
||||
* `details=0` - *Optional*, indicates if detailed info
|
||||
will be collected, `1` = yes, `0` = no.
|
||||
|
||||
* `keepDirs=1` - *Optional*, indicates if directories info
|
||||
will be collected, `1` = yes, `0` = no.
|
||||
|
||||
* `keepFiles=1` - *Optional*, indicates if files info
|
||||
will be collected, `1` = yes, `0` = no.
|
||||
|
||||
* `longFormat=0` - *Optional*, indicates if output be
|
||||
in long format, `1` = yes, `0` = no.
|
||||
|
||||
* `fileExt=` - *Optional*, if not missing then indicates
|
||||
file extension to filter out results.
|
||||
|
||||
* `maxDepth=0` - *Optional*, if not zero then indicates
|
||||
maximum depth of search in the root path.
|
||||
|
||||
---
|
||||
|
||||
### EXAMPLES AND USECASES: ####################################################
|
||||
|
||||
**EXAMPLE 1.** Get list of files and directories:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 2.** Get detailed info:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result2,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 3.** Get only files info:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result3,keepDirs=0)
|
||||
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result5,keepDirs=0,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 4.** Get only directories info:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result4,keepFiles=0)
|
||||
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result6,keepFiles=0,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 5.** Filter out by `sas` extension:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(~/,ODS=work.result7,fileExt=sas)
|
||||
|
||||
%dirsAndFiles(~/,ODS=work.result8,fileExt=sas,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 6.** Keep result in the long format:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(~/,ODS=work.result9,details=1,longFormat=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 7.** Get info for maximum depth of 2:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(C:\SAS_WORK\,ODS=work.result10,details=1,maxDepth=2)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 8.** How locked/unavailable files are handled:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(%sysfunc(pathname(WORK)),ODS=work.result11,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
**EXAMPLE 9.** Not existing directory:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
%dirsAndFiles(%sysfunc(pathname(WORK))/noSuchDir,ODS=work.result12,details=1)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## License ####################################################################
|
||||
|
||||
|
||||
BIN
baseplus.zip
BIN
baseplus.zip
Binary file not shown.
BIN
hist/1.19.0/baseplus.zip
Normal file
BIN
hist/1.19.0/baseplus.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user