mirror of
https://github.com/SASPAC/baseplus.git
synced 2026-01-03 16:10:05 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b95c4154df | ||
|
|
d769d10a61 | ||
|
|
d58133fa40 | ||
|
|
2d127ddb9f | ||
|
|
c99c9f38f8 | ||
|
|
1cbc5de18f | ||
|
|
2cad099652 | ||
|
|
bfd3a9d0d9 | ||
|
|
ab7feaa15a | ||
|
|
01b1300a55 |
@@ -47,10 +47,12 @@ libname NEW "%workPath()/new";
|
|||||||
%put %tranwrd(Miss Joan Smith,Miss,Ms.);
|
%put %tranwrd(Miss Joan Smith,Miss,Ms.);
|
||||||
|
|
||||||
%put %date() %time() %datetime();
|
%put %date() %time() %datetime();
|
||||||
|
|
||||||
|
%put %monthShift(2023,1,-5);
|
||||||
```
|
```
|
||||||
and more.
|
and more.
|
||||||
|
|
||||||
SHA256 digest for the latest version of `BasePlus`: F*7EF23E80A2C03B29402183D97ECFF608B62BEDD9458848709B52DC362E6201B9
|
SHA256 digest for the latest version of `BasePlus`: F*D84CE41A550DC2D5C092C70C04A796E8329F34087A603BEF0CD366910C162E80
|
||||||
|
|
||||||
[**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus")
|
[**Documentation for BasePlus**](./baseplus.md "Documentation for BasePlus")
|
||||||
|
|
||||||
|
|||||||
586
baseplus.md
586
baseplus.md
@@ -45,6 +45,8 @@
|
|||||||
* [`%RainCloudPlot()` macro](#raincloudplot-macro)
|
* [`%RainCloudPlot()` macro](#raincloudplot-macro)
|
||||||
* [`%zipLibrary()` macro](#ziplibrary-macro)
|
* [`%zipLibrary()` macro](#ziplibrary-macro)
|
||||||
* [`%unzipLibrary()` macro](#unziplibrary-macro)
|
* [`%unzipLibrary()` macro](#unziplibrary-macro)
|
||||||
|
* [`%zipArch()` macro](#ziparch-macro)
|
||||||
|
* [`%unzipArch()` macro](#unziparch-macro)
|
||||||
* [`%LDSN()` macro](#ldsn-macro)
|
* [`%LDSN()` macro](#ldsn-macro)
|
||||||
* [`%LDsNm()` macro](#ldsnm-macro)
|
* [`%LDsNm()` macro](#ldsnm-macro)
|
||||||
* [`%LVarNm()` macro](#lvarnm-macro)
|
* [`%LVarNm()` macro](#lvarnm-macro)
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
* [`%today()` macro](#today-macro)
|
* [`%today()` macro](#today-macro)
|
||||||
* [`%time()` macro](#time-macro)
|
* [`%time()` macro](#time-macro)
|
||||||
* [`%datetime()` macro](#datetime-macro)
|
* [`%datetime()` macro](#datetime-macro)
|
||||||
|
* [`%monthShift()` macro](#monthshift-macro)
|
||||||
* [`%translate()` macro](#translate-macro)
|
* [`%translate()` macro](#translate-macro)
|
||||||
* [`%tranwrd()` macro](#tranwrd-macro)
|
* [`%tranwrd()` macro](#tranwrd-macro)
|
||||||
* [`%findDSwithVarVal()` macro](#finddswithvarval-macro)
|
* [`%findDSwithVarVal()` macro](#finddswithvarval-macro)
|
||||||
@@ -77,7 +80,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# The BasePlus package [ver. 1.31.0] <a name="baseplus-package"></a> ###############################################
|
# The BasePlus package [ver. 1.34.0] <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.
|
||||||
@@ -85,6 +88,7 @@ functions and functionalities I miss in the BASE SAS.
|
|||||||
It is inspired by various people, e.g.
|
It is inspired by various people, e.g.
|
||||||
- at the SAS-L discussion list
|
- at the SAS-L discussion list
|
||||||
- at the communities.sas.com (SASware Ballot Ideas)
|
- at the communities.sas.com (SASware Ballot Ideas)
|
||||||
|
- at StackOverflow
|
||||||
- at the Office...
|
- at the Office...
|
||||||
- etc.
|
- etc.
|
||||||
|
|
||||||
@@ -100,8 +104,6 @@ Kudos to all who inspired me to generate this package:
|
|||||||
*Kurt Bremser*,
|
*Kurt Bremser*,
|
||||||
*Leonid Batkhan*.
|
*Leonid Batkhan*.
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### BASIC EXAMPLES AND USECASES: ####################################################
|
### BASIC EXAMPLES AND USECASES: ####################################################
|
||||||
@@ -345,90 +347,148 @@ run;
|
|||||||
%put %today() %date() %time() %datetime();
|
%put %today() %date() %time() %datetime();
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**EXAMPLE 24** Months shifting:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%put
|
||||||
|
Past: %monthShift(2023, 1, -1)
|
||||||
|
Current: %monthShift(2023, 1 )
|
||||||
|
Future: %monthShift(2023, 1, +1)
|
||||||
|
;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**EXAMPLE 25** Zipping and unzipping directories:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
options dlCreateDir;
|
||||||
|
libname arch1 "%workPath()/testArch1";
|
||||||
|
libname arch2 "%workPath()/testArch2";
|
||||||
|
|
||||||
|
filename arch1 "%workPath()/testArch1";
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file arch1(test1.txt);
|
||||||
|
put "text for test file 1";
|
||||||
|
data _null_;
|
||||||
|
file arch1(test2.txt);
|
||||||
|
put "text for test file 2";
|
||||||
|
data _null_;
|
||||||
|
file arch1(test3.txt);
|
||||||
|
put "text for test file 3";
|
||||||
|
run;
|
||||||
|
|
||||||
|
data arch1.class(index=(name));
|
||||||
|
set sashelp.class;
|
||||||
|
run;
|
||||||
|
data arch1.cars(index=(model));
|
||||||
|
set sashelp.cars;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%zipArch(
|
||||||
|
archName2.zip
|
||||||
|
, pathRef = arch1
|
||||||
|
, target = %workPath()/testArch2
|
||||||
|
, list = 1
|
||||||
|
, overwrite = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
%unzipArch(
|
||||||
|
archName2.zip
|
||||||
|
, path = %workPath()/testArch2
|
||||||
|
, target = %workPath()/testArch2
|
||||||
|
, clean=1
|
||||||
|
, list=1
|
||||||
|
);
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Package contains:
|
Package contains:
|
||||||
1. macro bppipe
|
1. macro bppipe
|
||||||
2. macro deduplistc
|
2. macro deduplistc
|
||||||
3. macro deduplistp
|
3. macro deduplistp
|
||||||
4. macro deduplists
|
4. macro deduplists
|
||||||
5. macro deduplistx
|
5. macro deduplistx
|
||||||
6. macro dirsandfiles
|
6. macro dirsandfiles
|
||||||
7. macro functionexists
|
7. macro functionexists
|
||||||
8. macro getvars
|
8. macro getvars
|
||||||
9. macro intslist
|
9. macro intslist
|
||||||
10. macro ldsn
|
10. macro ldsn
|
||||||
11. macro ldsnm
|
11. macro ldsnm
|
||||||
12. macro lvarnm
|
12. macro lvarnm
|
||||||
13. macro lvarnmlab
|
13. macro lvarnmlab
|
||||||
14. macro qdeduplistx
|
14. macro qdeduplistx
|
||||||
15. macro qgetvars
|
15. macro qgetvars
|
||||||
16. macro qzipevalf
|
16. macro qzipevalf
|
||||||
17. macro raincloudplot
|
17. macro raincloudplot
|
||||||
18. macro repeattxt
|
18. macro repeattxt
|
||||||
19. macro splitdsintoblocks
|
19. macro splitdsintoblocks
|
||||||
20. macro splitdsintoparts
|
20. macro splitdsintoparts
|
||||||
21. macro symdelglobal
|
21. macro symdelglobal
|
||||||
22. macro unziplibrary
|
22. macro unziparch
|
||||||
23. macro zipevalf
|
23. macro unziplibrary
|
||||||
24. macro ziplibrary
|
24. macro ziparch
|
||||||
25. format bool
|
25. macro zipevalf
|
||||||
26. format boolz
|
26. macro ziplibrary
|
||||||
27. format ceil
|
27. format bool
|
||||||
28. format floor
|
28. format boolz
|
||||||
29. format int
|
29. format ceil
|
||||||
30. function arrfill
|
30. format floor
|
||||||
31. function arrfillc
|
31. format int
|
||||||
32. function arrmissfill
|
32. functions arrfill
|
||||||
33. function arrmissfillc
|
33. functions arrfillc
|
||||||
34. function arrmisstoleft
|
34. functions arrmissfill
|
||||||
35. function arrmisstoleftc
|
35. functions arrmissfillc
|
||||||
36. function arrmisstoright
|
36. functions arrmisstoleft
|
||||||
37. function arrmisstorightc
|
37. functions arrmisstoleftc
|
||||||
38. function bracketsc
|
38. functions arrmisstoright
|
||||||
39. function bracketsn
|
39. functions arrmisstorightc
|
||||||
40. function catxfc
|
40. functions bracketsc
|
||||||
41. function catxfi
|
41. functions bracketsn
|
||||||
42. function catxfj
|
42. functions catxfc
|
||||||
43. function catxfn
|
43. functions catxfi
|
||||||
44. function deldataset
|
44. functions catxfj
|
||||||
45. function semicolonc
|
45. functions catxfn
|
||||||
46. function semicolonn
|
46. functions deldataset
|
||||||
47. format brackets
|
47. functions semicolonc
|
||||||
48. format semicolon
|
48. functions semicolonn
|
||||||
49. proto qsortincbyprocproto
|
49. format brackets
|
||||||
50. function frommissingtonumberbs
|
50. format semicolon
|
||||||
51. function fromnumbertomissing
|
51. proto qsortincbyprocproto
|
||||||
52. function quicksort4notmiss
|
52. functions frommissingtonumberbs
|
||||||
53. function quicksorthash
|
53. functions fromnumbertomissing
|
||||||
54. function quicksorthashsddv
|
54. functions quicksort4notmiss
|
||||||
55. function quicksortlight
|
55. functions quicksorthash
|
||||||
56. macro date
|
56. functions quicksorthashsddv
|
||||||
57. macro datetime
|
57. functions quicksortlight
|
||||||
58. macro filepath
|
58. macro date
|
||||||
59. macro finddswithvarval
|
59. macro datetime
|
||||||
60. macro fmt
|
60. macro filepath
|
||||||
61. macro gettitle
|
61. macro finddswithvarval
|
||||||
62. macro infmt
|
62. macro fmt
|
||||||
63. macro letters
|
63. macro gettitle
|
||||||
64. macro libpath
|
64. macro infmt
|
||||||
65. macro minclude
|
65. macro letters
|
||||||
66. macro replist
|
66. macro libpath
|
||||||
67. macro time
|
67. macro minclude
|
||||||
68. macro today
|
68. macro monthshift
|
||||||
69. macro translate
|
69. macro replist
|
||||||
70. macro tranwrd
|
70. macro time
|
||||||
71. macro workpath
|
71. macro today
|
||||||
|
72. macro translate
|
||||||
|
73. macro tranwrd
|
||||||
|
74. macro workpath
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it
|
Package contains additional content, run: %loadPackageAddCnt(BasePlus) to load it
|
||||||
or look for the baseplus_AdditionalContent directory in the Packages fileref
|
or look for the baseplus_AdditionalContent directory in the Packages fileref
|
||||||
localization (only if additional content was deployed during the installation process).
|
localization (only if additional content was deployed during the installation process).
|
||||||
|
|
||||||
* SAS package generated by generatePackage, version 20231009 *
|
* SAS package generated by generatePackage, version 20231107 *
|
||||||
|
|
||||||
The SHA256 hash digest for package BasePlus:
|
The SHA256 hash digest for package BasePlus:
|
||||||
`F*7EF23E80A2C03B29402183D97ECFF608B62BEDD9458848709B52DC362E6201B9`
|
`F*D84CE41A550DC2D5C092C70C04A796E8329F34087A603BEF0CD366910C162E80`
|
||||||
|
|
||||||
---
|
---
|
||||||
# Content description ############################################################################################
|
# Content description ############################################################################################
|
||||||
@@ -3760,6 +3820,237 @@ run;
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## >>> `%zipArch()` macro: <<< <a name="ziparch-macro"></a> #######################
|
||||||
|
|
||||||
|
The zipArch() macro allows to ZIP content of a directory.
|
||||||
|
Macro is OS independent, the `XCMD` option is not required.
|
||||||
|
|
||||||
|
Content of zipped archive can be listed in the log.
|
||||||
|
|
||||||
|
Errors of decompression and are reported.
|
||||||
|
|
||||||
|
Macro **does not** include hidden files.
|
||||||
|
|
||||||
|
See examples below for the details.
|
||||||
|
|
||||||
|
### SYNTAX: ###################################################################
|
||||||
|
|
||||||
|
The basic syntax is the following, the `<...>` means optional parameters:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%zipArch(
|
||||||
|
archName
|
||||||
|
,path =
|
||||||
|
<,pathRef=>
|
||||||
|
<,target=>
|
||||||
|
<,targetRef=>
|
||||||
|
<,list=>
|
||||||
|
<,overwrite=>
|
||||||
|
<,dropList=>
|
||||||
|
)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Arguments description**:
|
||||||
|
|
||||||
|
1. `archName` - *Required*, name of the archive to be generated.
|
||||||
|
Name should be full, i.e., with the extension!
|
||||||
|
|
||||||
|
2. `path=` - *Required/Optional*, location of a directory to ZIP.
|
||||||
|
The path should be provided unquoted.
|
||||||
|
Has priority over the `pathRef` parameter.
|
||||||
|
|
||||||
|
* `pathRef=` - *Required/Optional*, fileref to location of a directory to ZIP.
|
||||||
|
The reference **has** to be pointing to single directory.
|
||||||
|
If provided with `path` - the `path` takes
|
||||||
|
priority over the `pathRef` parameter.
|
||||||
|
|
||||||
|
* `target=` - *Optional*, a path pointing to target location where
|
||||||
|
the archive will be generated.
|
||||||
|
The path should be provided unquoted.
|
||||||
|
Default value is `WORK` location.
|
||||||
|
Has priority over the `targetRef` parameter.
|
||||||
|
|
||||||
|
* `targetRef=` - *Optional*, fileref to a path pointing to target location
|
||||||
|
where the archive will be generated.
|
||||||
|
The reference **has** to be pointing to single directory.
|
||||||
|
If provided with `target` - the `target` takes
|
||||||
|
priority over the `targetRef` parameter.
|
||||||
|
|
||||||
|
* `list = 0` - *Optional*, default value is `0`,
|
||||||
|
indicates if zip content should be listed in the log.
|
||||||
|
`1` means *yes*, `0` means *no*.
|
||||||
|
|
||||||
|
* `overwrite = 0` - *Optional*, default value is `0`,
|
||||||
|
indicates if existing archive file should be overwritten.
|
||||||
|
`1` means *yes*, `0` means *no*.
|
||||||
|
|
||||||
|
* `overwrite = 1` - *Technical*, default value is `1`,
|
||||||
|
indicates if the "to-be-zipped-files-list"
|
||||||
|
data set should be deleted.
|
||||||
|
`1` means *yes*, `0` means *no*.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### EXAMPLES AND USECASES: ####################################################
|
||||||
|
|
||||||
|
**EXAMPLE 1.** Zip a directory . Example requires the `basePlus` package.
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
|
||||||
|
options dlCreateDir;
|
||||||
|
libname arch1 "%workPath()/testArch1";
|
||||||
|
libname arch2 "%workPath()/testArch2";
|
||||||
|
|
||||||
|
filename arch1 "%workPath()/testArch1";
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file arch1(test1.txt);
|
||||||
|
put "text for test file 1";
|
||||||
|
data _null_;
|
||||||
|
file arch1(test2.txt);
|
||||||
|
put "text for test file 2";
|
||||||
|
data _null_;
|
||||||
|
file arch1(test3.txt);
|
||||||
|
put "text for test file 3";
|
||||||
|
run;
|
||||||
|
|
||||||
|
data arch1.class(index=(name));
|
||||||
|
set sashelp.class;
|
||||||
|
run;
|
||||||
|
data arch1.cars(index=(model));
|
||||||
|
set sashelp.cars;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%zipArch(
|
||||||
|
archName1.zip
|
||||||
|
, path = %workPath()/testArch1
|
||||||
|
, list = 1
|
||||||
|
, overwrite = 1
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
%zipArch(
|
||||||
|
archName2.zip
|
||||||
|
, pathRef = arch1
|
||||||
|
, target = %workPath()/testArch2
|
||||||
|
, list = 1
|
||||||
|
, overwrite = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
%unzipArch(
|
||||||
|
archName2.zip
|
||||||
|
, path = %workPath()/testArch2
|
||||||
|
, target = %workPath()/testArch2
|
||||||
|
, clean=1
|
||||||
|
, list=1
|
||||||
|
);
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## >>> `%unzipArch()` macro: <<< <a name="unziparch-macro"></a> #######################
|
||||||
|
|
||||||
|
The unzipArch() macro allows to unzip content of a ZIP archive.
|
||||||
|
Macro is OS independent, the `XCMD` option is not required.
|
||||||
|
|
||||||
|
The `dlCreateDir` option is used under the hood.
|
||||||
|
|
||||||
|
Content of unzipped archive can be listed in the log.
|
||||||
|
|
||||||
|
Source files can be deleted after decompression.
|
||||||
|
Errors of decompression and are reported. If any occur
|
||||||
|
the deletion is suspended.
|
||||||
|
|
||||||
|
See examples below for the details.
|
||||||
|
|
||||||
|
### SYNTAX: ###################################################################
|
||||||
|
|
||||||
|
The basic syntax is the following, the `<...>` means optional parameters:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%unzipArch(
|
||||||
|
archName
|
||||||
|
<,path=>
|
||||||
|
<,pathRef=>
|
||||||
|
<,target=>
|
||||||
|
<,targetRef=>
|
||||||
|
<,list=>
|
||||||
|
<,clean=>
|
||||||
|
)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Arguments description**:
|
||||||
|
|
||||||
|
1. `archName` - *Required*, name of the ZIP archive to be extracted.
|
||||||
|
Name should be full, i.e., with the extension!
|
||||||
|
|
||||||
|
* `path=` - *Optional*, a path pointing to zipped file location.
|
||||||
|
The path should be provided unquoted.
|
||||||
|
Default value is `WORK` location.
|
||||||
|
|
||||||
|
* `pathRef=` - *Optional*, a fileref to path pointing to zipped file location.
|
||||||
|
The `path`, if not null, has precedense over the `pathRef`.
|
||||||
|
|
||||||
|
* `target=` - *Optional*, a path pointing to target location where
|
||||||
|
files will be extracted.
|
||||||
|
The path should be provided unquoted.
|
||||||
|
Default value is `WORK` location.
|
||||||
|
|
||||||
|
* `target=` - *Optional*, a fileref to path pointing to target location where
|
||||||
|
files will be extracted.
|
||||||
|
The `target`, if not null, has precedense over the `targetRef`.
|
||||||
|
|
||||||
|
* `list = 0` - *Optional*, default value is `0`,
|
||||||
|
indicates if zip content should be listed in the log.
|
||||||
|
`1` means *yes*, `0` means *no*.
|
||||||
|
|
||||||
|
* `clean = 0` - *Optional*, default value is `0`,
|
||||||
|
indicates if zip file should be deleted after unzipping.
|
||||||
|
`1` means *yes*, `0` means *no*.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### EXAMPLES AND USECASES: ####################################################
|
||||||
|
|
||||||
|
**EXAMPLE 1.** Unzip compressed archive. Example requires the `basePlus` package.
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
|
||||||
|
filename arch ZIP "%workPath()/testArch.zip";
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file arch(abc/test1.txt);
|
||||||
|
put "text for test file 1";
|
||||||
|
data _null_;
|
||||||
|
file arch(abc/subdir/test2.txt);
|
||||||
|
put "text for test file 2";
|
||||||
|
data _null_;
|
||||||
|
file arch(abc/subdir/test3.txt);
|
||||||
|
put "text for test file 3";
|
||||||
|
run;
|
||||||
|
|
||||||
|
%unzipArch(
|
||||||
|
testArch.zip
|
||||||
|
, path = %workPath()
|
||||||
|
, target = %workPath()
|
||||||
|
, list=1
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
filename pR "%workPath()";
|
||||||
|
|
||||||
|
%unzipArch(
|
||||||
|
testArch.zip
|
||||||
|
, pathRef = pR
|
||||||
|
, targetRef = pR
|
||||||
|
, clean=1
|
||||||
|
);
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## >>> `%LDSN()` macro: <<< <a name="ldsn-macro"></a> #######################
|
## >>> `%LDSN()` macro: <<< <a name="ldsn-macro"></a> #######################
|
||||||
|
|
||||||
The LDSN (Long DataSet Names) macro function
|
The LDSN (Long DataSet Names) macro function
|
||||||
@@ -5107,6 +5398,149 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## >>> `%monthShift()` macro: <<< <a name="monthshift-macro"></a> #######################
|
||||||
|
|
||||||
|
The monthShift() macro is a utility macro
|
||||||
|
which allows to shift "year-month" period by
|
||||||
|
a given number of "periods" (months).
|
||||||
|
|
||||||
|
The result is in the `YYYYMM` format but can be altered.
|
||||||
|
|
||||||
|
See examples below for the details.
|
||||||
|
|
||||||
|
The `%monthShift()` macro executes like a pure macro code.
|
||||||
|
|
||||||
|
### SYNTAX: ###################################################################
|
||||||
|
|
||||||
|
The basic syntax is the following, the `<...>` means optional parameters:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%monthShift(
|
||||||
|
< Y>
|
||||||
|
<,M>
|
||||||
|
<,shift>
|
||||||
|
<,ofmt=>
|
||||||
|
)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Arguments description**:
|
||||||
|
|
||||||
|
1. `Y` - *Optional*, a year from which counting starts.
|
||||||
|
If null the value is set to *system year*.
|
||||||
|
|
||||||
|
2. `M` - *Optional*, a month from which counting starts.
|
||||||
|
If null the value is set to `1`. Can be a number
|
||||||
|
(`1` to `12`) or a name (`June`, `OCTOBER`) or
|
||||||
|
a three letters short (`JAN`, `apr`).
|
||||||
|
|
||||||
|
3. `shift` - *Optional*, number of periods to shift.
|
||||||
|
If null the value is set to `0`.
|
||||||
|
Positive value shifts to the "future",
|
||||||
|
negative value shifts to the "past",
|
||||||
|
Can be an expression (e.g. `1+2*3`, see examples).
|
||||||
|
|
||||||
|
* `ofmt=YYMMn6.` - *Optional*, it is a format name used to
|
||||||
|
display the result. Default value is `YYMMn6.`
|
||||||
|
See examples.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### EXAMPLES AND USECASES: ####################################################
|
||||||
|
|
||||||
|
**EXAMPLE 1.** Shift one up and one down:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%put
|
||||||
|
Past: %monthShift(2023, 1, -1)
|
||||||
|
Current: %monthShift(2023, 1 )
|
||||||
|
Future: %monthShift(2023, 1, +1)
|
||||||
|
;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
**EXAMPLE 2.** Shift by expression:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%let n = 2;
|
||||||
|
%put
|
||||||
|
%monthShift(2023, 1, +1 + &n.*3)
|
||||||
|
;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
**EXAMPLE 3.** Shift with default values:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%put %monthShift();
|
||||||
|
%put %monthShift(2023);
|
||||||
|
%put %monthShift(2023,Jan);
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
**EXAMPLE 4.** Shift with months names:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%put
|
||||||
|
%monthShift(2023,Jan,-1)
|
||||||
|
%monthShift(2023,Feb,-2)
|
||||||
|
%monthShift(2023,Mar,-3)
|
||||||
|
%monthShift(2023,Apr,-4)
|
||||||
|
%monthShift(2023,May,-5)
|
||||||
|
%monthShift(2023,Jun,-6)
|
||||||
|
%monthShift(2023,Jul,-7)
|
||||||
|
%monthShift(2023,Aug,-8)
|
||||||
|
%monthShift(2023,Sep,-9)
|
||||||
|
%monthShift(2023,Oct,-10)
|
||||||
|
%monthShift(2023,Nov,-11)
|
||||||
|
%monthShift(2023,Dec,-12)
|
||||||
|
;
|
||||||
|
|
||||||
|
%put
|
||||||
|
%monthShift(2023,January,12)
|
||||||
|
%monthShift(2023,February,11)
|
||||||
|
%monthShift(2023,March,10)
|
||||||
|
%monthShift(2023,April,9)
|
||||||
|
%monthShift(2023,May,8)
|
||||||
|
%monthShift(2023,June,7)
|
||||||
|
%monthShift(2023,July,6)
|
||||||
|
%monthShift(2023,August,5)
|
||||||
|
%monthShift(2023,September,4)
|
||||||
|
%monthShift(2023,October,3)
|
||||||
|
%monthShift(2023,November,2)
|
||||||
|
%monthShift(2023,December,1)
|
||||||
|
;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
**EXAMPLE 5.** Play with formatting:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%put
|
||||||
|
%monthShift(2023, 1, +1 )
|
||||||
|
%monthShift(2023, 1, +1, ofmt=yymm7. )
|
||||||
|
%monthShift(2023, 1, +1, ofmt=yymmd7.)
|
||||||
|
%monthShift(2023, 1, +1, ofmt=yymms7.)
|
||||||
|
;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
**EXAMPLE 6.** Read monthly data with `noDSNFERR` option:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
data
|
||||||
|
A202210 A202211 A202212
|
||||||
|
A202301 A202302 A202303
|
||||||
|
A202304 A202305 A202306
|
||||||
|
A202307 A202308 A202309
|
||||||
|
;
|
||||||
|
set sashelp.class;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
options noDSNFERR;
|
||||||
|
data ALL;
|
||||||
|
set
|
||||||
|
A%monthShift(2023, 9, -12) - A%monthShift(2023, 9)
|
||||||
|
;
|
||||||
|
run;
|
||||||
|
options DSNFERR;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
## >>> `%translate()` macro: <<< <a name="translate-macro"></a> #######################
|
## >>> `%translate()` macro: <<< <a name="translate-macro"></a> #######################
|
||||||
|
|
||||||
|
|||||||
BIN
baseplus.zip
BIN
baseplus.zip
Binary file not shown.
5932
hist/1.32.0/baseplus.md
Normal file
5932
hist/1.32.0/baseplus.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.32.0/baseplus.zip
Normal file
BIN
hist/1.32.0/baseplus.zip
Normal file
Binary file not shown.
6020
hist/1.33.0/baseplus.md
Normal file
6020
hist/1.33.0/baseplus.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.33.0/baseplus.zip
Normal file
BIN
hist/1.33.0/baseplus.zip
Normal file
Binary file not shown.
6212
hist/1.34.0/baseplus.md
Normal file
6212
hist/1.34.0/baseplus.md
Normal file
File diff suppressed because it is too large
Load Diff
BIN
hist/1.34.0/baseplus.zip
Normal file
BIN
hist/1.34.0/baseplus.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user