diff --git a/README.md b/README.md index dde3732..7b4b82a 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,12 @@ format x bool.; %bpPIPE(ls -la ~/) %dirsAndFiles(C:\SAS_WORK\,ODS=work.result) + +%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$); ``` and more. -SHA256 digest for the latest version of `BasePlus`: F*B5BF05531BF78DCEBC436BD93311FED0436D83AA3D106ABFBAD96B04C7D63DF2 +SHA256 digest for the latest version of `BasePlus`: F*F39F38CE80A5D8EED3BC9F2413CD6DEF38E8657E5DCF427CBA8938EB8C4350B6 [**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus") diff --git a/baseplus.md b/baseplus.md index 1d28618..55c4433 100644 --- a/baseplus.md +++ b/baseplus.md @@ -51,12 +51,13 @@ * [`%LVarNmLab()` macro](#lvarnmlab-macro) * [`%bpPIPE()` macro](#bppipe-macro) * [`%dirsAndFiles()` macro](#dirsandfiles-macro) + * [`%repeatTxt()` macro](#repeattxt-macro) * [License](#license) --- -# The BasePlus package [ver. 1.19.1] ############################################### +# The BasePlus package [ver. 1.20.0] ############################################### The **BasePlus** package implements useful functions and functionalities I miss in the BASE SAS. @@ -231,60 +232,67 @@ run; %dirsAndFiles(C:\SAS_WORK\,ODS=work.result) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +**EXAMPLE 14** Text repetition: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas +%put %repeatTxt(#,15,s=$) HELLO SAS! %repeatTxt(#,15,s=$); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + --- Package contains: -1. macro bppipe -2. macro deduplistc -3. macro deduplistp -4. macro deduplists -5. macro deduplistx -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 +1. macro bppipe +2. macro deduplistc +3. macro deduplistp +4. macro deduplists +5. macro deduplistx +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 repeattxt +18. macro symdelglobal +19. macro unziplibrary +20. macro zipevalf +21. macro ziplibrary +22. format bool +23. format boolz +24. format ceil +25. format floor +26. format int +27. functions arrfill +28. functions arrfillc +29. functions arrmissfill +30. functions arrmissfillc +31. functions arrmisstoleft +32. functions arrmisstoleftc +33. functions arrmisstoright +34. functions arrmisstorightc +35. functions bracketsc +36. functions bracketsn +37. functions catxfc +38. functions catxfi +39. functions catxfj +40. functions catxfn +41. functions deldataset +42. functions semicolonc +43. functions semicolonn +44. format brackets +45. format semicolon +46. proto qsortincbyprocproto +47. functions frommissingtonumberbs +48. functions fromnumbertomissing +49. functions quicksort4notmiss +50. functions quicksorthash +51. functions quicksorthashsddv +52. functions quicksortlight + Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it or look for the baseplus_AdditionalContent directory in the Packages fileref @@ -293,7 +301,7 @@ localization (only if additional content was deployed during the installation pr * SAS package generated by generatePackage, version 20230411 * The SHA256 hash digest for package BasePlus: -`F*B5BF05531BF78DCEBC436BD93311FED0436D83AA3D106ABFBAD96B04C7D63DF2` +`F*F39F38CE80A5D8EED3BC9F2413CD6DEF38E8657E5DCF427CBA8938EB8C4350B6` --- # Content description ############################################################################################ @@ -4123,10 +4131,96 @@ The basic syntax is the following, the `<...>` means optional parameters: %dirsAndFiles(%sysfunc(pathname(WORK))/noSuchDir,ODS=work.result12,details=1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +--- + +## >>> `%repeatTxt()` macro: <<< ####################### + +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() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- diff --git a/baseplus.zip b/baseplus.zip index 5bb6f17..4eec6fa 100644 Binary files a/baseplus.zip and b/baseplus.zip differ diff --git a/hist/1.20.0/baseplus.zip b/hist/1.20.0/baseplus.zip new file mode 100644 index 0000000..4eec6fa Binary files /dev/null and b/hist/1.20.0/baseplus.zip differ