mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-02 13:00:05 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26d9c735fe | ||
|
|
11c0b95d7e | ||
|
|
be89c6b9c6 | ||
|
|
17b1239087 | ||
|
|
bbba37d8eb | ||
|
|
6ccc07a5bb | ||
|
|
b5e15bda11 | ||
|
|
160c1bc9d3 | ||
|
|
76297dc5d8 | ||
|
|
ea866123d9 | ||
|
|
75029a488f |
34
README.md
34
README.md
@@ -8,7 +8,7 @@ A **SAS package** is an automatically generated, single, stand alone *zip* file
|
||||
|
||||
The *purpose of a package* is to be a simple, and easy to access, code sharing medium, which will allow: on the one hand, to separate the code complex dependencies created by the developer from the user experience with the final product and, on the other hand, reduce developer's and user's unnecessary frustration related to a remote deployment process.
|
||||
|
||||
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. **The latest version** of SPF is **`20220420`**.
|
||||
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. **The latest version** of SPF is **`20220930`**.
|
||||
|
||||
To get started with SAS Packages try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
|
||||
|
||||
@@ -23,6 +23,13 @@ Short description of the SAS Packages Framework macros can be found [here](https
|
||||
- [SAS dla Administratorów i Praktyków 2020](https://www.youtube.com/watch?v=mXuep2k48Z8&feature=youtu.be&t=0s "SASAiP2020") (October 2020, in Polish)
|
||||
- [Boston Area SAS Users Group webinar](https://www.basug.org/videos?wix-vod-video-id=78067e61413d43d3a6951974b3bc3014&wix-vod-comp-id=comp-klv807gt "BASUG") (November 2020)
|
||||
- [SAS Global Forum 2021 V.E.](https://www.youtube.com/watch?v=hqexaQtGw88 "SGF2021") (May 20th, 2021)
|
||||
|
||||
---
|
||||
|
||||
### Initiative to add SAS Packages Framework to SAS Base/Viya:
|
||||
|
||||
A **SASware Ballot Idea** for adding *SAS Packages Framework* macros into Base SAS and Viya was submitted Friday, May 27th 2022. If you would like to support the idea visit this [communities.sas.com post](https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-SAS-Packages-Framework-to-the-SAS-Base-Viya/idi-p/815508) and up vote the idea!
|
||||
|
||||
---
|
||||
|
||||
### The User:
|
||||
@@ -73,6 +80,8 @@ To create your own package:
|
||||
|
||||
---
|
||||
|
||||
**Update**\[September 30th, 2022\]**:** **New dedicated repository:** *SASPAC - the SAS Packages Archive* **is available as new location for packages storage**. Location of SASPAC is: [`https://github.com/SASPAC`](https://github.com/SASPAC)
|
||||
|
||||
**Update**\[November 11th, 2021\]**:** `%extendPackagesFileref()` **macro is available**.
|
||||
|
||||
**Update**\[October 15th, 2020\]**:** `%previewPackage()` **macro is available**.
|
||||
@@ -98,7 +107,12 @@ If you find the SPF useful **share info** about it or **give it a [star](https:/
|
||||
---
|
||||
|
||||
## Available packages:
|
||||
Currently the following packages are available (see the `./packages` directory):
|
||||
|
||||
For "backward compatibility"/historical point of view the following packages are available under the `./packages` directory.
|
||||
|
||||
Since *September 2022* the default location for packages is **SASPAC - the SAS Packages Archive** located under: [`https://github.com/SASPAC`](https://github.com/SASPAC) where each package is stored as a separate repository with historical versions too.
|
||||
|
||||
Packages:
|
||||
|
||||
- **SQLinDS**\[2.2\], based on Mike Rhoads' article *Use the Full Power of SAS in Your Function-Style Macros*. The package allows to write SQL queries in the data step, e.g.
|
||||
```sas
|
||||
@@ -106,7 +120,7 @@ Currently the following packages are available (see the `./packages` directory):
|
||||
set %SQL(select * from sashelp.class order by age);
|
||||
run;
|
||||
```
|
||||
SHA256 digest for SQLinDS: 701B69BE71B99792803BCE7718ED486259310FFB92E6D77ED1BC029D9CC67B60
|
||||
SHA256 digest for SQLinDS: 96D0EFE02DF1AE0D7D875A10CAF7EF63CDEF85DD0CF9418934BEFAF0C067D453
|
||||
|
||||
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/sqlinds.md "Documentation for SQLinDS")
|
||||
|
||||
@@ -118,7 +132,7 @@ SHA256 digest for MacroCore: A23C29529F3CE7D0C8BEE9545C5D22D5B5594907547374A5135
|
||||
|
||||
- **DFA** (Dynamic Function Arrays)\[0.5\], contains set of macros and FCMP functions which implement: a dynamically allocated array, a stack, a fifo queue, an ordered stack, and a priority queue, run `%helpPackage(DFA,createDFArray)` to find examples.
|
||||
|
||||
SHA256 digest for DFA: 6B3FB0B06B47A7EF1BB004B483B0F39B8F553F7F16D02A7E24CDE388BBA704EA
|
||||
SHA256 digest for DFA: 5BFFCE78439E1CDDCBB15C95CD287AA4195BF64BB17DDB8FE374EC3535B4F491
|
||||
|
||||
[Documentation for DFA](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/dfa.md "Documentation for DFA")
|
||||
|
||||
@@ -141,12 +155,12 @@ SHA256 digest for DFA: 6B3FB0B06B47A7EF1BB004B483B0F39B8F553F7F16D02A7E24CDE388B
|
||||
which = 1:H:2
|
||||
);
|
||||
```
|
||||
SHA256 digest for macroArray: DF63B0E027827A82038F1C8422787A0BC569BA93104BA1778DB6DD088A5D255C
|
||||
SHA256 digest for macroArray: ED12BC96F8A4E9E7C4D651EC1E15479DB9B55D98B274B63C507ED842081F7AB7
|
||||
|
||||
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/macroarray.md "Documentation for macroArray")
|
||||
|
||||
|
||||
- **BasePlus**\[1.15\] 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);
|
||||
@@ -164,7 +178,7 @@ format x bool.;
|
||||
|
||||
%zipLibrary(sashelp,libOut=work)
|
||||
```
|
||||
SHA256 digest for BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D85B0B2DEDE4E9
|
||||
SHA256 digest for BasePlus: 56B260350FEB7D5118F581B9EFD1B9CE1F0298DCB9A4C000A7654E2FF3F0298C
|
||||
|
||||
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")
|
||||
|
||||
@@ -173,12 +187,12 @@ SHA256 digest for BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D8
|
||||
The dataset with functions can be shared between different operating systems
|
||||
and allows to generate macros on site without showing their code.
|
||||
|
||||
SHA256 digest for GSM: E6E2A6214EE7DC6E06AA76916A68B216DD7665184E63CF2C01F487A038E71B09
|
||||
SHA256 digest for GSM: 2AEBC150FBA99A4AAB0265A21C57E89200BFD96B633B898F32743D1C8831A159
|
||||
|
||||
[Documentation for GSM](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/gsm.md "Documentation for GSM")
|
||||
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA). Development of this package is currently on hold.
|
||||
|
||||
SHA256 digest for dynMacroArray: 7DA9BFDED37C18C4FB5BD7579A81A4B2578EEEF1546D1A3AB5C80DE07C88A615
|
||||
SHA256 digest for dynMacroArray: D7E0B8F85C05EBF8622204E0D2F3E990D48D0A9B3911051C3AD44DC98954DDCF
|
||||
|
||||
### ======
|
||||
|
||||
Binary file not shown.
Binary file not shown.
105
SPF/Macros/extendpackagesfileref.sas
Normal file
105
SPF/Macros/extendpackagesfileref.sas
Normal file
@@ -0,0 +1,105 @@
|
||||
/*+extendPackagesFileref+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro extendPackagesFileref(
|
||||
packages /* A valid fileref name,
|
||||
when empty the "packages" value is used */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20220930. Run %extendPackagesFileref(HELP) for help info.'
|
||||
;
|
||||
|
||||
%if %QUPCASE(&packages.) = HELP %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put ###########################################################################################;
|
||||
%put ### This is short help information for the `extendPackagesFileref` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and embedded inside the zip. #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%extendPackagesFileref())` macro lists directories pointed by #;
|
||||
%put # the packages fileref. It allows to add new dierctories to packages folder list. #;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packages` *Optional.* A valid fileref name, when empty the "packages" is used. #;
|
||||
%put # Use case: #;
|
||||
%put # `%nrstr(%%extendPackagesFileref()).` #;
|
||||
%put # #;
|
||||
%put # When used as: `%nrstr(%%extendPackagesFileref(HELP))` it displays this help information. #;
|
||||
%put # #;
|
||||
%put #-----------------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ##############################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and adding #;
|
||||
%put # new directory. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in one of "C:/SAS_PK1" or "C:/SAS_PK2" folders. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages ("C:/SAS_PK1" "C:/SAS_PK2"); %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( filename packages ("D:/NEW_DIR" %%extendPackagesFileref()); %%* add new directory; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put ###########################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDextendPackagesFileref;
|
||||
%end;
|
||||
|
||||
%if %superq(packages) = %then %let packages = packages;
|
||||
%if %qsysfunc(pathname(&packages.)) ne %then
|
||||
%do;
|
||||
%if %qsubstr(%qsysfunc(pathname(&packages.)), 1, 1) = %str(%() %then
|
||||
%do;
|
||||
%local length;
|
||||
%let length = %eval(%length(%qsysfunc(pathname(&packages.)))-2);
|
||||
%unquote(%qsubstr(%qsysfunc(pathname(&packages.)), 2, &length.))
|
||||
%end;
|
||||
%else "%sysfunc(pathname(&packages.))";
|
||||
%end;
|
||||
%ENDextendPackagesFileref:
|
||||
%mend extendPackagesFileref;
|
||||
|
||||
/* Examples:
|
||||
|
||||
filename packages "C:\";
|
||||
%include packages(SPFinit.sas)
|
||||
|
||||
%extendPackagesFileref(HELP)
|
||||
|
||||
filename packages (%extendPackagesFileref() "D:\");
|
||||
filename packages list;
|
||||
|
||||
filename packages clear;
|
||||
|
||||
filename packages "C:\";
|
||||
filename packages ("D:\" %extendPackagesFileref());
|
||||
filename packages list;
|
||||
|
||||
%put *%extendPackagesFileref()*;
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/**/
|
||||
2439
SPF/Macros/generatepackage.sas
Normal file
2439
SPF/Macros/generatepackage.sas
Normal file
File diff suppressed because it is too large
Load Diff
178
SPF/Macros/helppackage.sas
Normal file
178
SPF/Macros/helppackage.sas
Normal file
@@ -0,0 +1,178 @@
|
||||
/*+helpPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro helpPackage(
|
||||
packageName /* name of a package,
|
||||
e.g. myPackageFile.zip,
|
||||
required and not null */
|
||||
, helpKeyword /* phrase to search in help,
|
||||
when empty prints description
|
||||
"*" means print all help
|
||||
"license" prints license */
|
||||
, path = %sysfunc(pathname(packages)) /* location of a package,
|
||||
by default it looks for
|
||||
location of "packages" fileref */
|
||||
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
|
||||
, source2 = /*source2*/ /* option to print out details,
|
||||
null by default */
|
||||
, zip = zip /* standard package is zip (lowcase),
|
||||
e.g. %helpPackage(PiPackage,*)
|
||||
if the zip is not available use a folder
|
||||
unpack data to "pipackage.disk" folder
|
||||
and use helpPackage in the form:
|
||||
%helpPackage(PiPackage, *, zip=disk, options=)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to get help about SAS package, version 20220930. Run %helpPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `helpPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get help about SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and provided with #;
|
||||
%put # a single `help.sas` file (also embedded inside the zip). #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%helpPackage())` macro prints in the SAS log help #;
|
||||
%put # information about the package provided by the developer. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packageName` *Required.* Name of a package, e.g. myPackage, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%helpPackage(myPackage)).` #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # 2. `helpKeyword` *Optional.* A phrase to search in help, #;
|
||||
%put # - when empty prints description, #;
|
||||
%put # - "*" means: print all help, #;
|
||||
%put # - "license" prints the license. #;
|
||||
%put # #;
|
||||
%put # - `path=` *Optional.* Location of a package. By default it #;
|
||||
%put # looks for location of the **packages** fileref, i.e. #;
|
||||
%put # `%nrstr(%%sysfunc(pathname(packages)))` #;
|
||||
%put # #;
|
||||
%put # - `options=` *Optional.* Possible options for ZIP filename, #;
|
||||
%put # default value: `LOWCASE_MEMNAME` #;
|
||||
%put # #;
|
||||
%put # - `source2=` *Optional.* Option to print out details about #;
|
||||
%put # what is loaded, null by default. #;
|
||||
%put # #;
|
||||
%put # - `zip=` Standard package is zip (lowcase), #;
|
||||
%put # e.g. `%nrstr(%%helpPackage(PiPackage))`. #;
|
||||
%put # If the zip is not available use a folder. #;
|
||||
%put # Unpack data to "pipackage.disk" folder #;
|
||||
%put # and use helpPackage in the following form: #;
|
||||
%put # `%nrstr(%%helpPackage(PiPackage, ,zip=disk, options=))` #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%helpPackage(SQLinDS) %%* get help about the package; );
|
||||
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
|
||||
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofhelpPackage;
|
||||
%end;
|
||||
|
||||
/* local variables for options */
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
|
||||
%local _PackageFileref_;
|
||||
/* %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); */
|
||||
data _null_; call symputX("_PackageFileref_", "P" !! put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
|
||||
/* when the packages reference is multi-directory search for the first one containing the package */
|
||||
data _null_;
|
||||
exists = 0;
|
||||
length packages $ 32767 p $ 4096;
|
||||
packages = resolve(symget("path"));
|
||||
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
|
||||
do i = 1 to kcountw(packages, "()", "QS");
|
||||
p = dequote(kscanx(packages, i, "()", "QS"));
|
||||
exists + fileexist(catx("/", p, "%lowcase(&packageName.).&zip."));
|
||||
if exists then leave;
|
||||
end;
|
||||
if exists then call symputx("path", p, "L");
|
||||
run;
|
||||
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include &_PackageFileref_.(help.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
||||
|
||||
%ENDofhelpPackage:
|
||||
%mend helpPackage;
|
||||
|
||||
/*
|
||||
TODO:
|
||||
- macro for testing available packages in the packages folder [DONE] checkout: %listPackages()
|
||||
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
|
||||
*/
|
||||
|
||||
/* Macros to install SAS packages, version 20220930 */
|
||||
/* A SAS package is a zip file containing a group of files
|
||||
with SAS code (macros, functions, data steps generating
|
||||
data, etc.) wrapped up together and %INCLUDEed by
|
||||
a single load.sas file (also embedded inside the zip).
|
||||
*/
|
||||
|
||||
410
SPF/Macros/installpackage.sas
Normal file
410
SPF/Macros/installpackage.sas
Normal file
@@ -0,0 +1,410 @@
|
||||
/*+installPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro installPackage(
|
||||
packagesNames /* space separated list of packages names, without the zip extension */
|
||||
, sourcePath = /* location of the package, e.g. "www.some.page/", mind the "/" at the end */
|
||||
, mirror = 0 /* indicates which location for package source should be used */
|
||||
, version = /* indicates which version of a package to install */
|
||||
, replace = 1 /* 1 = replace if the package already exist, 0 = otherwise */
|
||||
, URLuser = /* user name for the password protected URLs */
|
||||
, URLpass = /* password for the password protected URLs */
|
||||
, URLoptions = /* options for the `sourcePath` URLs */
|
||||
)
|
||||
/secure
|
||||
minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to install SAS package, version 20220930. Run %%installPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put ##############################################################################################;
|
||||
%put ### This is short help information for the `installPackage` macro #;
|
||||
%put #--------------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to install SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and embedded inside the zip. #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%installPackage())` macro installs the package zip #;
|
||||
%put # in the packages folder. The process of installation is equivalent with #;
|
||||
%put # manual downloading the package zip file into the packages folder. #;
|
||||
%put # #;
|
||||
%put # In case the packages fileref is a multi-directory one the first directory #;
|
||||
%put # will be selected as a destination. #;
|
||||
%put # #;
|
||||
%put #--------------------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packagesNames` Space separated list of packages names _without_ #;
|
||||
%put # the zip extension, e.g. myPackage1 myPackage2, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%installPackage(myPackage1 myPackage2))`. #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # If the package name is *SPFinit* or *SASPackagesFramework* #;
|
||||
%put # then the framework itself is downloaded. #;
|
||||
%put # #;
|
||||
%put # - `sourcePath=` Location of the package, e.g. "www.some.web.page/" #;
|
||||
%put # Mind the "/" at the end of the path! #;
|
||||
%put # Current default location for packages is: #;
|
||||
%put # `https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/packages/` #;
|
||||
%put # Current default location for the framework is: #;
|
||||
%put # `https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/` #;
|
||||
%put # #;
|
||||
%put # - `mirror=` Indicates which web location for packages installation is used. #;
|
||||
%put # Value `0` indicates: #;
|
||||
%put # `https://raw.githubusercontent.com/SASPAC/` #;
|
||||
%put # Value `1` indicates: #;
|
||||
%put # `https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main` #;
|
||||
%put # Value `2` indicates: #;
|
||||
%put # `https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES` #;
|
||||
%put # Default value is `0`. #;
|
||||
%put # #;
|
||||
%put # - `version=` Indicates which historical version of a package to install. #;
|
||||
%put # Historical version are available only if `mirror=0` is set. #;
|
||||
%put # Default value is null which means "install the latest". #;
|
||||
%put # #;
|
||||
%put # - `replace=` With default value of `1` it causes existing package file #;
|
||||
%put # to be replaced by new downloaded file. #;
|
||||
%put # #;
|
||||
%put # - `URLuser=` A user name for the password protected URLs, no quotes needed. #;
|
||||
%put # #;
|
||||
%put # - `URLpass=` A password for the password protected URLs, no quotes needed. #;
|
||||
%put # #;
|
||||
%put # - `URLoptions=` Options for the `sourcePath` URLs filename. Consult the SAS #;
|
||||
%put # documentation for the further details. #;
|
||||
%put # #;
|
||||
%put #--------------------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example #################################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%helpPackage(SQLinDS) %%* get help about the package; );
|
||||
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
|
||||
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put ##############################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofinstallPackage;
|
||||
%end;
|
||||
|
||||
/* local variables for options */
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp stimer_tmp fullstimer_tmp msglevel_tmp;
|
||||
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let stimer_tmp = %sysfunc(getoption(stimer));
|
||||
%let fullstimer_tmp = %sysfunc(getoption(fullstimer));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N;
|
||||
|
||||
/*
|
||||
Reference:
|
||||
https://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhere/
|
||||
*/
|
||||
|
||||
/* in case the 'packages' fileref is multi-directory the first directory will be selected as a destination */
|
||||
data _null_;
|
||||
/* get the firstPackagesPath */
|
||||
call symputX("firstPackagesPath", dequote(kscanx(pathname("packages"), 1, "()", "QS")) ,"L");
|
||||
run;
|
||||
|
||||
%if %superq(sourcePath)= %then
|
||||
%do;
|
||||
%local SPFinitMirror;
|
||||
/* the defaults are: */
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/packages/;
|
||||
|
||||
%if 0 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/SASPAC/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
|
||||
%if 1 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/packages/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
|
||||
%if 2 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES/packages/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
%mirrorEnd:
|
||||
%put INFO: Source path is &sourcePath.;
|
||||
%end;
|
||||
|
||||
%local i;
|
||||
%do i = 1 %to %sysfunc(countw(&packagesNames., , S));
|
||||
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%local packageName packageSubDir;
|
||||
%let packageName = %scan(&packagesNames., &i., , S);
|
||||
|
||||
%put ;
|
||||
%put *** %lowcase(&packageName.) start *****************************************;
|
||||
%local in out _IOFileref_;
|
||||
data _null_; call symputX("_IOFileref_", put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
%let in = i&_IOFileref_.;
|
||||
%let out = o&_IOFileref_.;
|
||||
/* %let in = i%sysfunc(md5(&packageName.),hex7.); */
|
||||
/* %let out = o%sysfunc(md5(&packageName.),hex7.); */
|
||||
|
||||
/*options MSGLEVEL=i;*/
|
||||
%if %upcase(&packageName.) in (SPFINIT SASPACKAGEFRAMEWORK SASPACKAGESFRAMEWORK) %then
|
||||
%do;
|
||||
/* allows to install/download the framework file like any other package */
|
||||
filename &in URL
|
||||
"&SPFinitMirror."
|
||||
recfm=N lrecl=1;
|
||||
filename &out
|
||||
"&firstPackagesPath./SPFinit.sas"
|
||||
recfm=N lrecl=1;
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
%if 0 = %superq(mirror) %then
|
||||
%do;
|
||||
%let packageSubDir = %lowcase(&packageName.)/main/;
|
||||
%if %superq(version) ne %then
|
||||
%do;
|
||||
%let packageSubDir = %lowcase(&packageName.)/main/hist/&version./;
|
||||
%end;
|
||||
%end;
|
||||
filename &in URL "&sourcePath.&packageSubDir.%lowcase(&packageName.).zip"
|
||||
%if (%superq(URLuser) ne ) %then
|
||||
%do;
|
||||
user = "&URLuser."
|
||||
pass = "&URLuser."
|
||||
%end;
|
||||
&URLoptions.
|
||||
recfm=N lrecl=1;
|
||||
filename &out "&firstPackagesPath./%lowcase(&packageName.).zip" recfm=N lrecl=1;
|
||||
%end;
|
||||
/*
|
||||
filename in list;
|
||||
filename out list;
|
||||
*/
|
||||
/* copy the file byte-by-byte */
|
||||
data _null_;
|
||||
length filein 8 out_path in_path $ 4096;
|
||||
out_path = pathname ("&out");
|
||||
in_path = pathname ("&in" );
|
||||
|
||||
|
||||
filein = fopen( "&in", 'S', 1, 'B');
|
||||
if filein = 0 then
|
||||
put "ERROR: Source file:" /
|
||||
"ERROR- " in_path /
|
||||
"ERROR- is unavailable!";
|
||||
if filein > 0;
|
||||
|
||||
put @2 "Source information:";
|
||||
infonum = FOPTNUM(filein);
|
||||
length infoname $ 32 infoval $ 128;
|
||||
do i=1 to coalesce(infonum, -1);
|
||||
infoname = FOPTNAME(filein, i);
|
||||
infoval = FINFO(filein, infoname);
|
||||
put @4 infoname ":"
|
||||
/ @6 infoval
|
||||
;
|
||||
end;
|
||||
rc = FCLOSE(filein);
|
||||
put;
|
||||
|
||||
if FEXIST("&out") = 0 then
|
||||
do;
|
||||
put @2 "Installing the &packageName. package"
|
||||
/ @2 "in the &firstPackagesPath. directory.";
|
||||
rc = FCOPY("&in", "&out");
|
||||
end;
|
||||
else if FEXIST("&out") = 1 then
|
||||
do;
|
||||
if symgetn("replace")=1 then
|
||||
do;
|
||||
put @2 "The following file will be replaced during "
|
||||
/ @2 "instalation of the &packageName. package: "
|
||||
/ @5 out_path;
|
||||
rc = FDELETE("&out");
|
||||
rc = FCOPY("&in", "&out");
|
||||
end;
|
||||
else
|
||||
do;
|
||||
put @2 "The following file will NOT be replaced: "
|
||||
/ @5 out_path;
|
||||
rc = 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
put @2 "Done with return code " rc= "(zero = success)";
|
||||
run;
|
||||
|
||||
filename &in clear;
|
||||
filename &out clear;
|
||||
%put *** %lowcase(&packageName.) end *******************************************;
|
||||
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%end;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp.
|
||||
¬es_tmp. &source_tmp.
|
||||
&stimer_tmp. &fullstimer_tmp.
|
||||
msglevel=&msglevel_tmp.;
|
||||
|
||||
%ENDofinstallPackage:
|
||||
%mend installPackage;
|
||||
|
||||
/*** HELP START ***/
|
||||
|
||||
/*
|
||||
Filenames references "packages" and "package" are reserved keywords.
|
||||
The first one should be used to point local folder with packages.
|
||||
The second is used internally by macros.
|
||||
Do not use them otherwise than:
|
||||
filename packages "</the/folder/with/sas/packages>";
|
||||
since it may affect stability of the framework.
|
||||
**/
|
||||
|
||||
/* Example 1: Enabling the SAS Package Framework
|
||||
and loading the SQLinDS package from the local directory.
|
||||
|
||||
Assume that the SPFinit.sas file and the SQLinDS
|
||||
package (sqlinds.zip file) are located in
|
||||
the "C:/SAS_PACKAGES/" folder.
|
||||
|
||||
Run the following code in your SAS session:
|
||||
|
||||
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
%include packages(SPFinit.sas); %* enable the framework;
|
||||
|
||||
%helpPackage(SQLinDS) %* get help about the package;
|
||||
%loadPackage(SQLinDS) %* load the package content into the SAS session;
|
||||
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
|
||||
*/
|
||||
|
||||
/* Example 2: Enabling the SAS Package Framework
|
||||
from the local directory and installing & loading
|
||||
the SQLinDS package from the Internet.
|
||||
|
||||
Assume that the SPFinit.sas file
|
||||
is located in the "C:/SAS_PACKAGES/" folder.
|
||||
|
||||
Run the following code in your SAS session:
|
||||
|
||||
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
%include packages(SPFinit.sas); %* enable the framework;
|
||||
|
||||
%installPackage(SQLinDS) %* install the package from the Internet;
|
||||
%helpPackage(SQLinDS) %* get help about the package;
|
||||
%loadPackage(SQLinDS) %* load the package content into the SAS session;
|
||||
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
|
||||
*/
|
||||
|
||||
/* Example 3: Enabling the SAS Package Framework
|
||||
and installing & loading the SQLinDS package
|
||||
from the Internet.
|
||||
|
||||
Run the following code in your SAS session:
|
||||
|
||||
filename packages "%sysfunc(pathname(work))"; %* setup WORK as a temporary directory for packages;
|
||||
|
||||
filename spfinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPFinit.sas";
|
||||
%include spfinit; %* enable the framework;
|
||||
|
||||
%installPackage(SQLinDS) %* install the package from the Internet;
|
||||
%helpPackage(SQLinDS) %* get help about the package;
|
||||
%loadPackage(SQLinDS) %* load the package content into the SAS session;
|
||||
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
|
||||
*/
|
||||
|
||||
/* Example 4:
|
||||
Assume that the SPFinit.sas file and the SQLinDS package (sqlinds.zip file)
|
||||
are located in the "C:/SAS_PACKAGES/" folder.
|
||||
|
||||
In case when user SAS session does not support ZIP fileref
|
||||
the following solution could be used.
|
||||
|
||||
Unzip the packagename.zip content into the packagename.disk folder
|
||||
and run macros with the following options: ;
|
||||
|
||||
%loadPackage(packageName,zip=disk,options=)
|
||||
%helpPackage(packageName,,zip=disk,options=) %* mind the double comma!! ;
|
||||
%unloadPackage(packageName,zip=disk,options=)
|
||||
|
||||
*/
|
||||
|
||||
/* Example 5: Enabling the SAS Package Framework from the local directory
|
||||
and installing the SQLinDS package from the Internet.
|
||||
|
||||
Assume that the SPFinit.sas file is located in
|
||||
the "C:/SAS_PACKAGES/" folder.
|
||||
|
||||
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
%include packages(SPFinit.sas); %* enable the framework;
|
||||
|
||||
%installPackage(SQLinDS); %* install package;
|
||||
%installPackage(SQLinDS); %* overwrite already installed package;
|
||||
%installPackage(SQLinDS,replace=0); %* prevent overwrite installed package;
|
||||
|
||||
|
||||
%installPackage(NotExistingPackage); %* handling with not existing package;
|
||||
|
||||
*/
|
||||
|
||||
/*** HELP END ***/
|
||||
|
||||
/*** HELP START ***/
|
||||
|
||||
/* Macro to list SAS packages in packages folder.
|
||||
|
||||
Version 20220930
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
data, etc.) wrapped up together and %INCLUDEed by
|
||||
a single load.sas file (also embedded inside the zip).
|
||||
*/
|
||||
/*
|
||||
* Example 1: Set local packages directory, enable the framework,
|
||||
and list packages in the local repository.
|
||||
|
||||
filename packages "C:\SAS_PACKAGES";
|
||||
%include packages(SPFinit.sas);
|
||||
%listPackages()
|
||||
|
||||
*/
|
||||
/*** HELP END ***/
|
||||
|
||||
180
SPF/Macros/listpackages.sas
Normal file
180
SPF/Macros/listpackages.sas
Normal file
@@ -0,0 +1,180 @@
|
||||
/*+listPackages+*/
|
||||
|
||||
%macro listPackages()/secure PARMBUFF
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20220930.'
|
||||
;
|
||||
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put ###########################################################################################;
|
||||
%put ### This is short help information for the `listPackages` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list available SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and embedded inside the zip. #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%listPackages())` macro lists packages available #;
|
||||
%put # in the packages folder. List is printed inthe SAS Log. #;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # NO PARAMETERS #;
|
||||
%put # #;
|
||||
%put # When used as: `%nrstr(%%listPackages(HELP))` it displays this help information. #;
|
||||
%put # #;
|
||||
%put #-----------------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ##############################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and listing #;
|
||||
%put # available packages. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%listPackages() %%* list available packages; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put ###########################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDoflistPackages;
|
||||
%end;
|
||||
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp filesWithCodes;
|
||||
|
||||
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
|
||||
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX;
|
||||
|
||||
data _null_;
|
||||
length baseAll $ 32767;
|
||||
baseAll = pathname("packages");
|
||||
|
||||
if baseAll = " " then
|
||||
do;
|
||||
put "NOTE: The file reference PACKAGES is not assigned.";
|
||||
stop;
|
||||
end;
|
||||
|
||||
if char(baseAll,1) ^= "(" then baseAll = quote(strip(baseAll)); /* for paths with spaces */
|
||||
|
||||
do k = 1 to kcountw(baseAll, "()", "QS"); drop k;
|
||||
base = dequote(kscanx(baseAll, k, "()", "QS"));
|
||||
|
||||
length folder $ 64 file $ 1024 folderRef fileRef $ 8;
|
||||
|
||||
folderRef = "_%sysfunc(datetime(), hex6.)0";
|
||||
|
||||
rc=filename(folderRef, base);
|
||||
folderid=dopen(folderRef);
|
||||
|
||||
putlog " ";
|
||||
put "/*" 100*"+" ;
|
||||
do i=1 to dnum(folderId); drop i;
|
||||
|
||||
if i = 1 then
|
||||
do;
|
||||
put " #";
|
||||
put " # Listing packages for: " base;
|
||||
put " #";
|
||||
end;
|
||||
|
||||
folder = dread(folderId, i);
|
||||
|
||||
fileRef = "_%sysfunc(datetime(), hex6.)1";
|
||||
rc = filename(fileRef, catx("/", base, folder));
|
||||
fileId = dopen(fileRef);
|
||||
|
||||
EOF = 0;
|
||||
if fileId = 0 and lowcase(kscanx(folder, -1, ".")) = 'zip' then
|
||||
do;
|
||||
file = catx('/',base, folder);
|
||||
|
||||
rc1 = filename("package", strip(file), 'zip', 'member="description.sas"');
|
||||
rcE = fexist("package");
|
||||
rc2 = filename("package", " ");
|
||||
|
||||
if rcE then /* if the description.sas exists in the zip then read it */
|
||||
do;
|
||||
putlog " * ";
|
||||
length nn $ 96;
|
||||
if (96-lengthn(file)) < 1 then
|
||||
put " * " file;
|
||||
else
|
||||
do;
|
||||
nn = repeat("*", (96-lengthn(file)));
|
||||
put " * " file nn;
|
||||
end;
|
||||
|
||||
infile _DUMMY_ ZIP FILEVAR=file member="description.sas" end=EOF;
|
||||
|
||||
do until(EOF);
|
||||
input;
|
||||
if strip(upcase(kscanx(_INFILE_,1,":"))) in ("PACKAGE" "TITLE" "VERSION" "AUTHOR" "MAINTAINER" "LICENSE") then
|
||||
do;
|
||||
_INFILE_ = kscanx(_INFILE_,1,":") !! ":" !! kscanx(_INFILE_,2,":");
|
||||
putlog " * " _INFILE_;
|
||||
end;
|
||||
if strip(upcase(strip(_INFILE_))) =: "DESCRIPTION START:" then leave;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
rc = dclose(fileId);
|
||||
rc = filename(fileRef);
|
||||
end;
|
||||
|
||||
putlog " * ";
|
||||
put 100*"+" "*/";
|
||||
rc = dclose(folderid);
|
||||
rc = filename(folderRef);
|
||||
end;
|
||||
|
||||
stop;
|
||||
run;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
%ENDoflistPackages:
|
||||
%mend listPackages;
|
||||
|
||||
|
||||
/*** HELP START ***/
|
||||
|
||||
/* Macro to generate SAS packages.
|
||||
|
||||
Version 20220930
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
data, etc.) wrapped up together and %INCLUDEed by
|
||||
a single load.sas file (also embedded inside the zip).
|
||||
|
||||
See examples below.
|
||||
*/
|
||||
|
||||
/*** HELP END ***/
|
||||
|
||||
198
SPF/Macros/loadpackage.sas
Normal file
198
SPF/Macros/loadpackage.sas
Normal file
@@ -0,0 +1,198 @@
|
||||
/*+loadPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro loadPackage(
|
||||
packageName /* name of a package,
|
||||
e.g. myPackage,
|
||||
required and not null */
|
||||
, path = %sysfunc(pathname(packages)) /* location of a package,
|
||||
by default it looks for
|
||||
location of "packages" fileref */
|
||||
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
|
||||
, source2 = /*source2*/ /* option to print out details,
|
||||
null by default */
|
||||
, requiredVersion = . /* option to test if loaded package
|
||||
is provided in required version */
|
||||
, lazyData = /* a list of names of lazy datasets
|
||||
to be loaded, if not null then
|
||||
datasets from the list are loaded
|
||||
instead of a package, asterisk
|
||||
means "load all datasets" */
|
||||
, zip = zip /* standard package is zip (lowcase),
|
||||
e.g. %loadPackage(PiPackage)
|
||||
if the zip is not available use a folder
|
||||
unpack data to "pipackage.disk" folder
|
||||
and use loadPackage in the form:
|
||||
%loadPackage(PiPackage, zip=disk, options=)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load SAS package, version 20220930. Run %loadPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `loadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to *load* SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and included by #;
|
||||
%put # a single `load.sas` file (also embedded inside the zip). #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%loadPackage())` macro loads package content, i.e. macros, #;
|
||||
%put # functions, formats, etc., from the zip into the SAS session. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packageName` *Required.* Name of a package, e.g. myPackage, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%loadPackage(myPackage)).` #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # - `path=` *Optional.* Location of a package. By default it #;
|
||||
%put # looks for location of the **packages** fileref, i.e. #;
|
||||
%put # `%nrstr(%%sysfunc(pathname(packages)))` #;
|
||||
%put # #;
|
||||
%put # - `options=` *Optional.* Possible options for ZIP filename, #;
|
||||
%put # default value: `LOWCASE_MEMNAME` #;
|
||||
%put # #;
|
||||
%put # - `source2=` *Optional.* Option to print out details about #;
|
||||
%put # what is loaded, null by default. #;
|
||||
%put # #;
|
||||
%put # - `requiredVersion=` *Optional.* Option to test if the loaded #;
|
||||
%put # package is provided in required version, #;
|
||||
%put # default value: `.` #;
|
||||
%put # #;
|
||||
%put # - `lazyData=` *Optional.* A list of names of lazy datasets to be #;
|
||||
%put # loaded. If not null datasets from the list are loaded #;
|
||||
%put # instead of the package. #;
|
||||
%put # An asterisk (*) means *load all lazy datasets*. #;
|
||||
%put # #;
|
||||
%put # - `zip=` Standard package is zip (lowcase), #;
|
||||
%put # e.g. `%nrstr(%%loadPackage(PiPackage))`. #;
|
||||
%put # If the zip is not available use a folder. #;
|
||||
%put # Unpack data to "pipackage.disk" folder #;
|
||||
%put # and use loadPackage in the following form: #;
|
||||
%put # `%nrstr(%%loadPackage(PiPackage, zip=disk, options=))` #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put ### Example #####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%helpPackage(SQLinDS) %%* get help about the package; );
|
||||
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
|
||||
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofloadPackage;
|
||||
%end;
|
||||
/* local variables for options */
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp stimer_tmp fullstimer_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let stimer_tmp = %sysfunc(getoption(stimer));
|
||||
%let fullstimer_tmp = %sysfunc(getoption(fullstimer));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N;
|
||||
|
||||
%local _PackageFileref_;
|
||||
/* %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); */
|
||||
data _null_; call symputX("_PackageFileref_", "P" !! put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
|
||||
/* when the packages reference is multi-directory search for the first one containing the package */
|
||||
data _null_;
|
||||
exists = 0;
|
||||
length packages $ 32767 p $ 4096;
|
||||
packages = resolve(symget("path"));
|
||||
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
|
||||
do i = 1 to kcountw(packages, "()", "QS");
|
||||
p = dequote(kscanx(packages, i, "()", "QS"));
|
||||
exists + fileexist(catx("/", p, "%lowcase(&packageName.).&zip."));
|
||||
if exists then leave;
|
||||
end;
|
||||
if exists then call symputx("path", p, "L");
|
||||
run;
|
||||
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
/* test if required version of package is "good enough" */
|
||||
%if %sysevalf(&requiredVersion. > &packageVersion.) %then
|
||||
%do;
|
||||
%put ERROR: Package &packageName. will not be loaded!;
|
||||
%put ERROR- Required version is &requiredVersion.;
|
||||
%put ERROR- Provided version is &packageVersion.;
|
||||
%put ERROR- Verify installed version of the package.;
|
||||
%put ERROR- ;
|
||||
%GOTO WrongVersionOFPackage; /*%RETURN;*/
|
||||
%end;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%if %bquote(&lazyData.) = %then
|
||||
%do;
|
||||
%include &_PackageFileref_.(load.sas) / &source2.;
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
%include &_PackageFileref_.(lazydata.sas) / &source2.;
|
||||
%end;
|
||||
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
%WrongVersionOFPackage:
|
||||
|
||||
/* restore optionos */
|
||||
options ls = &ls_tmp. ps = &ps_tmp.
|
||||
¬es_tmp. &source_tmp.
|
||||
&stimer_tmp. &fullstimer_tmp.
|
||||
msglevel=&msglevel_tmp.;
|
||||
|
||||
%ENDofloadPackage:
|
||||
%mend loadPackage;
|
||||
|
||||
101
SPF/Macros/loadpackages.sas
Normal file
101
SPF/Macros/loadpackages.sas
Normal file
@@ -0,0 +1,101 @@
|
||||
/*+loadPackageS+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro loadPackageS(
|
||||
packagesNames /* A comma separated list of packages names,
|
||||
e.g. myPackage, myPackage1, myPackage2, myPackage3
|
||||
required and not null.
|
||||
Package version, in brackets behind a package name,
|
||||
can be provided, e.g.
|
||||
%loadPackageS(myPackage1(1.7), myPackage2(4.2))
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20220930. Run %loadPackages() for help info.'
|
||||
parmbuff
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `loadPackageS` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and embedded inside the zip. #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%loadPackageS())` allows to load multiple packages at one time, #;
|
||||
%put # *ONLY* from the *ZIP* with *DEFAULT OPTIONS*, into the SAS session. #;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packagesNames` A comma separated list of packages names, #;
|
||||
%put # e.g. myPackage, myPackage1, myPackage2, myPackage3 #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%loadPackageS(myPackage1, myPackage2, myPackage3))`. #;
|
||||
%put # Package version, in brackets behind a package name, can #;
|
||||
%put # be provided, example is the following: #;
|
||||
%put # `%nrstr(%%loadPackageS(myPackage1(1.7), myPackage2(4.2)))`. #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS DFA) %%* install packages from the Internet; );
|
||||
%put %nrstr( %%loadPackageS(SQLinDS, DFA) %%* load packags content into the SAS session; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofloadPackageS;
|
||||
%end;
|
||||
|
||||
%local lengthOfsyspbuff numberOfPackagesNames i packageElement packageName packageVersion;
|
||||
|
||||
%let lengthOfsyspbuff = %qsysfunc(length(&syspbuff.));
|
||||
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), %str((._,)), KDA));
|
||||
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str(,)));
|
||||
|
||||
%put NOTE: List of packages to be loaded contains &numberOfPackagesNames. element(s).;
|
||||
%put NOTE- The list is: &packagesNames..;
|
||||
%put NOTE- ;
|
||||
|
||||
%do i = 1 %to &numberOfPackagesNames.;
|
||||
%let packageElement = %qscan(&packagesNames., &i., %str(,) );
|
||||
%let packageName = %qscan(&packageElement., 1, %str(()));
|
||||
%let packageVersion = %qscan(&packageElement., 2, %str(()));
|
||||
%if %superq(packageVersion) = %then %let packageVersion = .;
|
||||
|
||||
%loadPackage(%unquote(&packageName.), requiredVersion=%unquote(&packageVersion.))
|
||||
%end;
|
||||
|
||||
%ENDofloadPackageS:
|
||||
%mend loadPackageS;
|
||||
|
||||
|
||||
159
SPF/Macros/previewpackage.sas
Normal file
159
SPF/Macros/previewpackage.sas
Normal file
@@ -0,0 +1,159 @@
|
||||
/*+previewPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro previewPackage(
|
||||
packageName /* name of a package,
|
||||
e.g. myPackageFile.zip,
|
||||
required and not null */
|
||||
, helpKeyword /* phrase to search for preview,
|
||||
when empty prints description
|
||||
"*" means prints all */
|
||||
, path = %sysfunc(pathname(packages)) /* location of a package,
|
||||
by default it looks for
|
||||
location of "packages" fileref */
|
||||
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
|
||||
, source2 = /*source2*/ /* option to print out details,
|
||||
null by default */
|
||||
, zip = zip /* standard package is zip (lowcase),
|
||||
e.g. %previewPackage(PiPackage,*)
|
||||
if the zip is not available use a folder
|
||||
unpack data to "pipackage.disk" folder
|
||||
and use previewPackage in the form:
|
||||
%previewPackage(PiPackage, *, zip=disk, options=)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to preview content of a SAS package, version 20220930. Run %previewPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `previewPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get previwe of a SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and provided with #;
|
||||
%put # a single `preview.sas` file (also embedded inside the zip). #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%previewPackage())` macro prints, in the SAS log, content #;
|
||||
%put # of a SAS package. Code of a package is printed out. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packageName` *Required.* Name of a package, e.g. myPackage, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%previewPackage(myPackage)).` #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # 2. `helpKeyword` *Optional.* A phrase to search in preview, #;
|
||||
%put # - when empty prints description, #;
|
||||
%put # - "*" means: print all preview. #;
|
||||
%put # #;
|
||||
%put # - `path=` *Optional.* Location of a package. By default it #;
|
||||
%put # looks for location of the **packages** fileref, i.e. #;
|
||||
%put # `%nrstr(%%sysfunc(pathname(packages)))` #;
|
||||
%put # #;
|
||||
%put # - `options=` *Optional.* Possible options for ZIP filename, #;
|
||||
%put # default value: `LOWCASE_MEMNAME` #;
|
||||
%put # #;
|
||||
%put # - `source2=` *Optional.* Option to print out details about #;
|
||||
%put # what is loaded, null by default. #;
|
||||
%put # #;
|
||||
%put # - `zip=` Standard package is zip (lowcase), #;
|
||||
%put # e.g. `%nrstr(%%previewPackage(PiPackage))`. #;
|
||||
%put # If the zip is not available use a folder. #;
|
||||
%put # Unpack data to "pipackage.disk" folder #;
|
||||
%put # and use previewPackage in the following form: #;
|
||||
%put # `%nrstr(%%previewPackage(PiPackage, , zip=disk, options=))` #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%previewPackage(SQLinDS) %%* get content of the package; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofpreviewPackage;
|
||||
%end;
|
||||
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
|
||||
%local _PackageFileref_;
|
||||
/* %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); */
|
||||
data _null_; call symputX("_PackageFileref_", "P" !! put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
|
||||
/* when the packages reference is multi-directory search for the first one containing the package */
|
||||
data _null_;
|
||||
exists = 0;
|
||||
length packages $ 32767 p $ 4096;
|
||||
packages = resolve(symget("path"));
|
||||
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
|
||||
do i = 1 to kcountw(packages, "()", "QS");
|
||||
p = dequote(kscanx(packages, i, "()", "QS"));
|
||||
exists + fileexist(catx("/", p, "%lowcase(&packageName.).&zip."));
|
||||
if exists then leave;
|
||||
end;
|
||||
if exists then call symputx("path", p, "L");
|
||||
run;
|
||||
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include &_PackageFileref_.(preview.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
||||
|
||||
%ENDofpreviewPackage:
|
||||
%mend previewPackage;
|
||||
|
||||
156
SPF/Macros/unloadpackage.sas
Normal file
156
SPF/Macros/unloadpackage.sas
Normal file
@@ -0,0 +1,156 @@
|
||||
/*+unloadPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro unloadPackage(
|
||||
packageName /* name of a package,
|
||||
e.g. myPackage,
|
||||
required and not null */
|
||||
, path = %sysfunc(pathname(packages)) /* location of a package,
|
||||
by default it looks for
|
||||
location of "packages" fileref */
|
||||
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
|
||||
, source2 = /*source2*/ /* option to print out details,
|
||||
null by default */
|
||||
, zip = zip /* standard package is zip (lowcase),
|
||||
e.g. %unloadPackage(PiPackage)
|
||||
if the zip is not available use a folder
|
||||
unpack data to "pipackage.disk" folder
|
||||
and use unloadPackage in the form:
|
||||
%unloadPackage(PiPackage, zip=disk, options=)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to unload SAS package, version 20220930. Run %unloadPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `unloadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to unload SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and provided with #;
|
||||
%put # a single `unload.sas` file (also embedded inside the zip). #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%unloadPackage())` macro clears the package content #;
|
||||
%put # from the SAS session. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packageName` *Required.* Name of a package, e.g. myPackage, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%unloadPackage(myPackage)).` #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # - `path=` *Optional.* Location of a package. By default it #;
|
||||
%put # looks for location of the **packages** fileref, i.e. #;
|
||||
%put # `%nrstr(%%sysfunc(pathname(packages)))` #;
|
||||
%put # #;
|
||||
%put # - `options=` *Optional.* Possible options for ZIP filename, #;
|
||||
%put # default value: `LOWCASE_MEMNAME` #;
|
||||
%put # #;
|
||||
%put # - `source2=` *Optional.* Option to print out details about #;
|
||||
%put # what is loaded, null by default. #;
|
||||
%put # #;
|
||||
%put # - `zip=` Standard package is zip (lowcase), #;
|
||||
%put # e.g. `%nrstr(%%unloadPackage(PiPackage))`. #;
|
||||
%put # If the zip is not available use a folder. #;
|
||||
%put # Unpack data to "pipackage.disk" folder #;
|
||||
%put # and use unloadPackage in the following form: #;
|
||||
%put # `%nrstr(%%unloadPackage(PiPackage, zip=disk, options=))` #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put ### Example #####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%helpPackage(SQLinDS) %%* get help about the package; );
|
||||
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
|
||||
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofunloadPackage;
|
||||
%end;
|
||||
|
||||
/* local variables for options */
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
|
||||
%local _PackageFileref_;
|
||||
/* %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); */
|
||||
data _null_; call symputX("_PackageFileref_", "P" !! put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
|
||||
/* when the packages reference is multi-directory search for the first one containing the package */
|
||||
data _null_;
|
||||
exists = 0;
|
||||
length packages $ 32767 p $ 4096;
|
||||
packages = resolve(symget("path"));
|
||||
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
|
||||
do i = 1 to kcountw(packages, "()", "QS");
|
||||
p = dequote(kscanx(packages, i, "()", "QS"));
|
||||
exists + fileexist(catx("/", p, "%lowcase(&packageName.).&zip."));
|
||||
if exists then leave;
|
||||
end;
|
||||
if exists then call symputx("path", p, "L");
|
||||
run;
|
||||
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename &_PackageFileref_. &ZIP.
|
||||
"&path./%lowcase(&packageName.).&zip." %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include &_PackageFileref_.(unload.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
||||
|
||||
%ENDofunloadPackage:
|
||||
%mend unloadPackage;
|
||||
|
||||
176
SPF/Macros/verifypackage.sas
Normal file
176
SPF/Macros/verifypackage.sas
Normal file
@@ -0,0 +1,176 @@
|
||||
/*+verifyPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro verifyPackage(
|
||||
packageName /* name of a package,
|
||||
e.g. myPackage,
|
||||
required and not null */
|
||||
, path = %sysfunc(pathname(packages)) /* location of a package,
|
||||
by default it looks for
|
||||
location of "packages" fileref */
|
||||
, hash = /* The SHA256 hash digest for
|
||||
the package generated by
|
||||
hashing_file() function, SAS 9.4M6 */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20220930. Run %verifyPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
%local options_tmp ;
|
||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||
%put ;
|
||||
%put #################################################################################;
|
||||
%put ### This is short help information for the `verifyPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
%put # data, etc.) wrapped up together and embedded inside the zip. #;
|
||||
%put # #;
|
||||
%put # The `%nrstr(%%verifyPackage())` macro generate package SHA256 hash #;
|
||||
%put # and compares it with the one provided by the user. #;
|
||||
%put # #;
|
||||
%put # #;
|
||||
%put # *Minimum SAS version required for the process is 9.4M6.* #;
|
||||
%put # #;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `packageName` Name of a package, e.g. myPackage, #;
|
||||
%put # Required and not null, default use case: #;
|
||||
%put # `%nrstr(%%loadPackage(myPackage))`. #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # - `hash=` A value of the package `SHA256` hash. #;
|
||||
%put # Provided by the user. #;
|
||||
%put # #;
|
||||
%put # - `path=` Location of a package. By default it looks for #;
|
||||
%put # location of the "packages" fileref, i.e. #;
|
||||
%put # `%nrstr(%%sysfunc(pathname(packages)))` #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put #### Example ####################################################################;
|
||||
%put # #;
|
||||
%put # Enabling the SAS Package Framework #;
|
||||
%put # from the local directory and installing & loading #;
|
||||
%put # the SQLinDS package from the Internet. #;
|
||||
%put # #;
|
||||
%put # Assume that the `SPFinit.sas` file #;
|
||||
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
|
||||
%put # #;
|
||||
%put # Run the following code in your SAS session: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* set-up a directory for packages; );
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%installPackage(SQLinDS) %%* install the package from the Internet; );
|
||||
%put %nrstr( %%verifyPackage%(SQLinDS, %%* verify the package with provided hash; );
|
||||
%put %nrstr( hash=HDA478ANJ3HKHRY327FGE88HF89VH89HFFFV73GCV98RF390VB4%) );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofverifyPackage;
|
||||
%end;
|
||||
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp stimer_tmp fullstimer_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
%let stimer_tmp = %sysfunc(getoption(stimer));
|
||||
%let fullstimer_tmp = %sysfunc(getoption(fullstimer));
|
||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||
|
||||
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N;
|
||||
|
||||
%local _PackageFileref_;
|
||||
/* %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); */
|
||||
data _null_; call symputX("_PackageFileref_", "P" !! put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
|
||||
|
||||
/* when the packages reference is multi-directory search for the first one containing the package */
|
||||
data _null_;
|
||||
exists = 0;
|
||||
length packages $ 32767 p $ 4096;
|
||||
packages = resolve(symget("path"));
|
||||
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
|
||||
do i = 1 to kcountw(packages, "()", "QS");
|
||||
p = dequote(kscanx(packages, i, "()", "QS"));
|
||||
exists + fileexist(catx("/", p, "%lowcase(&packageName.).zip"));
|
||||
if exists then leave;
|
||||
end;
|
||||
if exists then call symputx("path", p, "L");
|
||||
run;
|
||||
|
||||
filename &_PackageFileref_.
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).zip"
|
||||
;
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
/* create hash SHA256 id *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
%local HASHING_FILE_exist;
|
||||
%let HASHING_FILE_exist = 0;
|
||||
|
||||
%if %sysfunc(exist(sashelp.vfunc, VIEW)) %then
|
||||
%do;
|
||||
data _null_;
|
||||
set sashelp.vfunc(keep=fncname);
|
||||
where fncname = "HASHING_FILE";
|
||||
call symputX('HASHING_FILE_exist', 1, "L");
|
||||
stop;
|
||||
run;
|
||||
%end;
|
||||
|
||||
%if &HASHING_FILE_exist. = 1 %then
|
||||
%do;
|
||||
options notes;
|
||||
filename &_PackageFileref_. list;
|
||||
|
||||
data _null_;
|
||||
SHA256 = HASHING_FILE("SHA256", "&_PackageFileref_.", 4);
|
||||
providedHash = "&hash.";
|
||||
put "Provided Hash: " providedHash;
|
||||
put "SHA256 digest: " SHA256;
|
||||
put " ";
|
||||
|
||||
if SHA256 = providedHash then
|
||||
do;
|
||||
put "NOTE: Package verification SUCCESSFUL.";
|
||||
put "NOTE- Generated hash is EQUAL to the provided one.";
|
||||
end;
|
||||
else
|
||||
do;
|
||||
put "ERROR: Package verification FAILED!!";
|
||||
put "ERROR- Generated hash is DIFFERENT than the provided one.";
|
||||
put "ERROR- Confirm if the package is genuine.";
|
||||
end;
|
||||
run;
|
||||
%let HASHING_FILE_exist = 0;
|
||||
%end;
|
||||
%else
|
||||
%put WARNING: Verification impossible! Minimum SAS version required for the process is 9.4M6. ;
|
||||
/*-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp.
|
||||
¬es_tmp. &source_tmp.
|
||||
&stimer_tmp. &fullstimer_tmp.
|
||||
msglevel=&msglevel_tmp.;
|
||||
|
||||
%ENDofverifyPackage:
|
||||
%mend verifyPackage;
|
||||
/**/
|
||||
|
||||
@@ -21,7 +21,7 @@ A **SAS package** is an automatically generated, single, stand alone *zip* file
|
||||
|
||||
The *purpose of a package* is to be a simple, and easy to access, code sharing medium, which will allow: on the one hand, to separate the code complex dependencies created by the developer from the user experience with the final product and, on the other hand, reduce developer's and user's unnecessary frustration related to a remote deployment process.
|
||||
|
||||
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20220420`**.
|
||||
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20220930`**.
|
||||
|
||||
**To get started with SAS Packages** try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
|
||||
|
||||
@@ -39,7 +39,7 @@ After assigning the directory do not change them when using the SPF since it may
|
||||
## This is short help information for the `installPackage` macro <a name="installpackage"></a>
|
||||
--------------------------------------------------------------------------------------------
|
||||
|
||||
Macro to install SAS packages, version `20220420`
|
||||
Macro to install SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -70,8 +70,21 @@ After assigning the directory do not change them when using the SPF since it may
|
||||
Current default location for the framework is:
|
||||
`https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/`
|
||||
|
||||
- `mirror=` Indicates which web location for packages installation is used.
|
||||
Value `0` indicates:
|
||||
`https://raw.githubusercontent.com/SASPAC/`
|
||||
Value `1` indicates:
|
||||
`https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main`
|
||||
Value `2` indicates:
|
||||
`https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES`
|
||||
Default value is `0`.
|
||||
|
||||
- `version=` Indicates which historical version of a package to install.
|
||||
Historical version are available only if `mirror=0` is set.
|
||||
Default value is null which means "install the latest".
|
||||
|
||||
- `replace=` With default value of `1` it causes existing package file
|
||||
to be replaceed by new downloaded file.
|
||||
to be replaced by new downloaded file.
|
||||
|
||||
- `URLuser=` A user name for the password protected URLs, no quotes needed.
|
||||
|
||||
@@ -108,7 +121,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `helpPackage` macro <a name="helppackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to get help about SAS packages, version `20220420`
|
||||
Macro to get help about SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -178,7 +191,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `loadPackage` macro <a name="loadpackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to *load* SAS packages, version `20220420`
|
||||
Macro to *load* SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -251,7 +264,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `loadPackageS` macro <a name="loadpackages"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro wrapper for the loadPackage macro, version `20220420`
|
||||
Macro wrapper for the loadPackage macro, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -300,7 +313,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `unloadPackage` macro <a name="unloadpackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to unload SAS packages, version `20220420`
|
||||
Macro to unload SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -365,7 +378,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `listPackages` macro <a name="listpackages"></a>
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
Macro to list available SAS packages, version `20220420`
|
||||
Macro to list available SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -406,7 +419,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `verifyPackage` macro <a name="verifypackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to verify SAS package with it hash digest, version `20220420`
|
||||
Macro to verify SAS package with it hash digest, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -460,7 +473,7 @@ filename packages "C:/SAS_PACKAGES"; %* set-up a directory for packages;
|
||||
## This is short help information for the `previewPackage` macro <a name="previewpackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to get previwe of a SAS packages, version `20220420`
|
||||
Macro to get previwe of a SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -527,7 +540,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
## This is short help information for the `generatePackage` macro <a name="generatepackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to generate SAS packages, version `20220420`
|
||||
Macro to generate SAS packages, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -567,10 +580,15 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
- `sasexe=` Location of a DIRECTORY where the SAS binary is located,
|
||||
if null (the default) then the `!SASROOT` is used.
|
||||
|
||||
- `sascfgfile=` Location of a FILE with testing session configuration
|
||||
- `sascfgFile=` Location of a FILE with testing session configuration
|
||||
parameters, if null (the default) then no config file
|
||||
is pointed during the SAS invocation,
|
||||
if set to `DEF` then the `!SASROOT/sasv9.cfg` is used.
|
||||
|
||||
- `delTestWork=` Indicates if `WORK` directories generated by user tests
|
||||
should be deleted, i.e. the (NO)WORKTERM option is set.
|
||||
The default value: `1` means "delete tests work".
|
||||
Available values are `0` and `1`.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -703,7 +721,7 @@ All files have to have `.sas` extension. Other files are ignored.
|
||||
## This is short help information for the `extendPackagesFileref` macro <a name="extendpackagesfileref"></a>
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
Macro to list directories pointed by 'packages' fileref, version `20220420`
|
||||
Macro to list directories pointed by 'packages' fileref, version `20220930`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
|
||||
418
SPF/SPFinit.sas
418
SPF/SPFinit.sas
@@ -42,7 +42,7 @@
|
||||
- to unload, or
|
||||
- to generate SAS packages.
|
||||
|
||||
Version 20220420.
|
||||
Version 20220930.
|
||||
See examples below.
|
||||
|
||||
A SAS package is a zip file containing a group of files
|
||||
@@ -53,6 +53,7 @@
|
||||
|
||||
/*** HELP END ***/
|
||||
|
||||
/*+loadPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro loadPackage(
|
||||
@@ -81,7 +82,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load SAS package, version 20220420. Run %loadPackage() for help info.'
|
||||
des = 'Macro to load SAS package, version 20220930. Run %loadPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -96,7 +97,7 @@ des = 'Macro to load SAS package, version 20220420. Run %loadPackage() for help
|
||||
%put ### This is short help information for the `loadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to *load* SAS packages, version `20220420` #;
|
||||
%put # Macro to *load* SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -250,6 +251,7 @@ des = 'Macro to load SAS package, version 20220420. Run %loadPackage() for help
|
||||
%ENDofloadPackage:
|
||||
%mend loadPackage;
|
||||
|
||||
/*+unloadPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro unloadPackage(
|
||||
@@ -271,7 +273,7 @@ des = 'Macro to load SAS package, version 20220420. Run %loadPackage() for help
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to unload SAS package, version 20220420. Run %unloadPackage() for help info.'
|
||||
des = 'Macro to unload SAS package, version 20220930. Run %unloadPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -286,7 +288,7 @@ des = 'Macro to unload SAS package, version 20220420. Run %unloadPackage() for h
|
||||
%put ### This is short help information for the `unloadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to unload SAS packages, version `20220420` #;
|
||||
%put # Macro to unload SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -405,6 +407,7 @@ des = 'Macro to unload SAS package, version 20220420. Run %unloadPackage() for h
|
||||
%ENDofunloadPackage:
|
||||
%mend unloadPackage;
|
||||
|
||||
/*+helpPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro helpPackage(
|
||||
@@ -430,7 +433,7 @@ des = 'Macro to unload SAS package, version 20220420. Run %unloadPackage() for h
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to get help about SAS package, version 20220420. Run %helpPackage() for help info.'
|
||||
des = 'Macro to get help about SAS package, version 20220930. Run %helpPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -445,7 +448,7 @@ des = 'Macro to get help about SAS package, version 20220420. Run %helpPackage()
|
||||
%put ### This is short help information for the `helpPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get help about SAS packages, version `20220420` #;
|
||||
%put # Macro to get help about SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -575,17 +578,21 @@ TODO:
|
||||
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
|
||||
*/
|
||||
|
||||
/* Macros to install SAS packages, version 20220420 */
|
||||
/* Macros to install SAS packages, version 20220930 */
|
||||
/* A SAS package is a zip file containing a group of files
|
||||
with SAS code (macros, functions, data steps generating
|
||||
data, etc.) wrapped up together and %INCLUDEed by
|
||||
a single load.sas file (also embedded inside the zip).
|
||||
*/
|
||||
|
||||
/*+installPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro installPackage(
|
||||
packagesNames /* space separated list of packages names, without the zip extension */
|
||||
, sourcePath = /* location of the package, e.g. "www.some.page/", mind the "/" at the end */
|
||||
, mirror = 0 /* indicates which location for package source should be used */
|
||||
, version = /* indicates which version of a package to install */
|
||||
, replace = 1 /* 1 = replace if the package already exist, 0 = otherwise */
|
||||
, URLuser = /* user name for the password protected URLs */
|
||||
, URLpass = /* password for the password protected URLs */
|
||||
@@ -594,7 +601,7 @@ TODO:
|
||||
/secure
|
||||
minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to install SAS package, version 20220420. Run %%installPackage() for help info.'
|
||||
des = 'Macro to install SAS package, version 20220930. Run %%installPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
%do;
|
||||
@@ -609,7 +616,7 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
%put ### This is short help information for the `installPackage` macro #;
|
||||
%put #--------------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to install SAS packages, version `20220420` #;
|
||||
%put # Macro to install SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -641,8 +648,21 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
%put # Current default location for the framework is: #;
|
||||
%put # `https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/` #;
|
||||
%put # #;
|
||||
%put # - `mirror=` Indicates which web location for packages installation is used. #;
|
||||
%put # Value `0` indicates: #;
|
||||
%put # `https://raw.githubusercontent.com/SASPAC/` #;
|
||||
%put # Value `1` indicates: #;
|
||||
%put # `https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main` #;
|
||||
%put # Value `2` indicates: #;
|
||||
%put # `https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES` #;
|
||||
%put # Default value is `0`. #;
|
||||
%put # #;
|
||||
%put # - `version=` Indicates which historical version of a package to install. #;
|
||||
%put # Historical version are available only if `mirror=0` is set. #;
|
||||
%put # Default value is null which means "install the latest". #;
|
||||
%put # #;
|
||||
%put # - `replace=` With default value of `1` it causes existing package file #;
|
||||
%put # to be replaceed by new downloaded file. #;
|
||||
%put # to be replaced by new downloaded file. #;
|
||||
%put # #;
|
||||
%put # - `URLuser=` A user name for the password protected URLs, no quotes needed. #;
|
||||
%put # #;
|
||||
@@ -707,13 +727,39 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
|
||||
%if %superq(sourcePath)= %then
|
||||
%do;
|
||||
%local SPFinitMirror;
|
||||
/* the defaults are: */
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/packages/;
|
||||
|
||||
%if 0 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/SASPAC/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
|
||||
%if 1 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/packages/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
|
||||
%if 2 = %superq(mirror) %then
|
||||
%do;
|
||||
%let SPFinitMirror = https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES/SPF/SPFinit.sas;
|
||||
%let sourcePath = https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/SAS_PACKAGES/packages/;
|
||||
%goto mirrorEnd;
|
||||
%end;
|
||||
%mirrorEnd:
|
||||
%put INFO: Source path is &sourcePath.;
|
||||
%end;
|
||||
|
||||
%local i;
|
||||
%do i = 1 %to %sysfunc(countw(&packagesNames., , S));
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
%local packageName;
|
||||
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%local packageName packageSubDir;
|
||||
%let packageName = %scan(&packagesNames., &i., , S);
|
||||
|
||||
%put ;
|
||||
@@ -730,7 +776,7 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
%do;
|
||||
/* allows to install/download the framework file like any other package */
|
||||
filename &in URL
|
||||
"https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas"
|
||||
"&SPFinitMirror."
|
||||
recfm=N lrecl=1;
|
||||
filename &out
|
||||
"&firstPackagesPath./SPFinit.sas"
|
||||
@@ -738,7 +784,15 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
filename &in URL "&sourcePath.%lowcase(&packageName.).zip"
|
||||
%if 0 = %superq(mirror) %then
|
||||
%do;
|
||||
%let packageSubDir = %lowcase(&packageName.)/main/;
|
||||
%if %superq(version) ne %then
|
||||
%do;
|
||||
%let packageSubDir = %lowcase(&packageName.)/main/hist/&version./;
|
||||
%end;
|
||||
%end;
|
||||
filename &in URL "&sourcePath.&packageSubDir.%lowcase(&packageName.).zip"
|
||||
%if (%superq(URLuser) ne ) %then
|
||||
%do;
|
||||
user = "&URLuser."
|
||||
@@ -809,7 +863,7 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
filename &in clear;
|
||||
filename &out clear;
|
||||
%put *** %lowcase(&packageName.) end *******************************************;
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%end;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp.
|
||||
@@ -923,7 +977,7 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
|
||||
/* Macro to list SAS packages in packages folder.
|
||||
|
||||
Version 20220420
|
||||
Version 20220930
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -941,9 +995,10 @@ des = 'Macro to install SAS package, version 20220420. Run %%installPackage() fo
|
||||
*/
|
||||
/*** HELP END ***/
|
||||
|
||||
/*+listPackages+*/
|
||||
|
||||
%macro listPackages()/secure PARMBUFF
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20220420.'
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20220930.'
|
||||
;
|
||||
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
||||
%do;
|
||||
@@ -958,7 +1013,7 @@ des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HE
|
||||
%put ### This is short help information for the `listPackages` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list available SAS packages, version `20220420` #;
|
||||
%put # Macro to list available SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -1108,7 +1163,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
/* Macro to generate SAS packages.
|
||||
|
||||
Version 20220420
|
||||
Version 20220930
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -1120,8 +1175,9 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
/*** HELP END ***/
|
||||
|
||||
|
||||
/*+generatePackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro generatePackage(
|
||||
filesLocation /* location of package files
|
||||
e.g. %sysfunc(pathname(work))/%lowcase(&packageName.) */
|
||||
@@ -1135,13 +1191,16 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
if null (the default) the WORK is used */
|
||||
,sasexe= /* a DIRECTORY where the SAS binary is located,
|
||||
if null (the default) then the !SASROOT is used */
|
||||
,sascfgfile= /* a FILE with testing session configuration parameters
|
||||
,sascfgFile= /* a FILE with testing session configuration parameters
|
||||
if null (the default) then no config file is pointed
|
||||
during the SAS invocation,
|
||||
if set to DEF then the !SASROOT/sasv9.cfg is used */
|
||||
,delTestWork=1 /* indicates if `WORK` directories generated by user tests
|
||||
should be deleted, i.e. the (NO)WORKTERM option is set,
|
||||
default value 1 means "delete tests work" */
|
||||
)/secure minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to generate SAS packages, version 20220420. Run %generatePackage() for help info.'
|
||||
des = 'Macro to generate SAS packages, version 20220930. Run %generatePackage() for help info.'
|
||||
;
|
||||
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
|
||||
%do;
|
||||
@@ -1156,7 +1215,7 @@ des = 'Macro to generate SAS packages, version 20220420. Run %generatePackage()
|
||||
%put ### This is short help information for the `generatePackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to generate SAS packages, version `20220420` #;
|
||||
%put # Macro to generate SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -1196,11 +1255,16 @@ des = 'Macro to generate SAS packages, version 20220420. Run %generatePackage()
|
||||
%put # - `sasexe=` Location of a DIRECTORY where the SAS binary is located, #;
|
||||
%put # if null (the default) then the `!SASROOT` is used. #;
|
||||
%put # #;
|
||||
%put # - `sascfgfile=` Location of a FILE with testing session configuration #;
|
||||
%put # - `sascfgFile=` Location of a FILE with testing session configuration #;
|
||||
%put # parameters, if null (the default) then no config file #;
|
||||
%put # is pointed during the SAS invocation, #;
|
||||
%put # if set to `DEF` then the `!SASROOT/sasv9.cfg` is used. #;
|
||||
%put # #;
|
||||
%put # - `delTestWork=` Indicates if `WORK` directories generated by user tests #;
|
||||
%put # should be deleted, i.e. the (NO)WORKTERM option is set. #;
|
||||
%put # The default value: `1` means "delete tests work". #;
|
||||
%put # Available values are `0` and `1`. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
@@ -1208,11 +1272,12 @@ des = 'Macro to generate SAS packages, version 20220420. Run %generatePackage()
|
||||
%GOTO ENDofgeneratePackage;
|
||||
%end;
|
||||
|
||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_ _PackageFileref_;
|
||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _DUMMY_ _RC_ _PackageFileref_;
|
||||
%let zipReferrence = _%sysfunc(datetime(), hex6.)_;
|
||||
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
|
||||
%let _DESCR_ = _%sysfunc(datetime(), hex6.)d;
|
||||
%let _LIC_ = _%sysfunc(datetime(), hex6.)l;
|
||||
%let _DUMMY_ = _%sysfunc(datetime(), hex6.)_;
|
||||
|
||||
/* collect package metadata from the description.sas file */
|
||||
filename &_DESCR_. "&filesLocation./description.sas" lrecl = 1024;
|
||||
@@ -1221,7 +1286,10 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
|
||||
|
||||
%if %sysfunc(fexist(&_DESCR_.)) %then
|
||||
%do;
|
||||
%put NOTE: Creating package metadata;
|
||||
%put NOTE- ;
|
||||
%put NOTE: Verifying package metadata;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE- ;
|
||||
|
||||
%local packageName /* name of the package, required */
|
||||
packageVersion /* version of the package, required */
|
||||
@@ -1233,6 +1301,10 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
|
||||
packageRequired /* optional */
|
||||
packageReqPackages /* optional */
|
||||
;
|
||||
|
||||
%local qlenmax_fstimer_tmp;
|
||||
%let qlenmax_fstimer_tmp = %sysfunc(getoption(quotelenmax)) %sysfunc(getoption(stimer)) %sysfunc(getoption(fullstimer));
|
||||
options NOquotelenmax NOstimer NOfullstimer;
|
||||
data _null_;
|
||||
infile &_DESCR_.;
|
||||
input;
|
||||
@@ -1253,6 +1325,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
|
||||
otherwise;
|
||||
end;
|
||||
run;
|
||||
options &qlenmax_fstimer_tmp.;
|
||||
|
||||
/* test for required descriptors */
|
||||
%if (%nrbquote(&packageName.) = )
|
||||
@@ -1318,6 +1391,105 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
|
||||
%abort;
|
||||
%end;
|
||||
|
||||
%if %bquote(&packageRequired.) ne %then
|
||||
%do;
|
||||
/* turn off the note about quoted string length */
|
||||
%local qlenmax_fstimer_tmp;
|
||||
%let qlenmax_fstimer_tmp = %sysfunc(getoption(quotelenmax)) %sysfunc(getoption(stimer)) %sysfunc(getoption(fullstimer));
|
||||
options NOquotelenmax NOstimer NOfullstimer;
|
||||
%local tryExcept;
|
||||
%let tryExcept = 0;
|
||||
data _null_;
|
||||
rc = dosubl('options nonotes nosource;
|
||||
filename &_DUMMY_. DUMMY;
|
||||
proc printto log = &_DUMMY_.; run;' !!
|
||||
'%let SYSCC = 0;
|
||||
data _null_;
|
||||
length rq $ 164;
|
||||
do rq = &packageRequired.;
|
||||
end;
|
||||
run;' !!
|
||||
'%let tryExcept = &SYSCC.; filename &_DUMMY_. clear;');
|
||||
|
||||
tryExcept = symgetn('tryExcept');
|
||||
|
||||
put "NOTE: Required test: " rc= tryExcept= "(double 0 is success)";
|
||||
|
||||
if tryExcept then
|
||||
do;
|
||||
put 'ERROR: Your Required list seems to be problematic.';
|
||||
put 'ERROR- Check the description.sas file.';
|
||||
put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.';
|
||||
put 'ERROR- "SAS Component1", "SAS Component2", "SAS Component3"';
|
||||
put 'ERROR- Provided value is:';
|
||||
length R $ 32767;
|
||||
R = symget('packageRequired');
|
||||
put 'ERROR- ' R;
|
||||
end;
|
||||
else
|
||||
rc = dosubl('title; options nonotes nosource ps=max ls=99 nodate nonumber nostimer;
|
||||
data _null_;
|
||||
length rq $ 64; put "Required:";
|
||||
do rq = &packageRequired.;
|
||||
put "- " rq;
|
||||
end;
|
||||
run;');
|
||||
run;
|
||||
/* turn on the original value of the note about quoted string length */
|
||||
options &qlenmax_fstimer_tmp.;
|
||||
%if &tryExcept. %then %abort;
|
||||
%end;
|
||||
|
||||
%if %bquote(&packageReqPackages.) ne %then
|
||||
%do;
|
||||
/* turn off the note about quoted string length */
|
||||
%local qlenmax_fstimer_tmp;
|
||||
%let qlenmax_fstimer_tmp = %sysfunc(getoption(quotelenmax)) %sysfunc(getoption(stimer)) %sysfunc(getoption(fullstimer));
|
||||
options NOquotelenmax NOstimer NOfullstimer;
|
||||
|
||||
%local tryExcept;
|
||||
%let tryExcept = 0;
|
||||
data _null_;
|
||||
rc = dosubl('options nonotes nosource;
|
||||
filename &_DUMMY_. DUMMY;
|
||||
proc printto log = &_DUMMY_.; run;' !!
|
||||
'%let SYSCC = 0;
|
||||
data _null_;
|
||||
length rq $ 64;
|
||||
do rq = &packageReqPackages.;
|
||||
end;
|
||||
run;' !!
|
||||
'%let tryExcept = &SYSCC.; filename &_DUMMY_. clear;');
|
||||
|
||||
tryExcept = symgetn('tryExcept');
|
||||
|
||||
put "NOTE: ReqPackages test: " rc= tryExcept= "(double 0 is success)";
|
||||
|
||||
if tryExcept then
|
||||
do;
|
||||
put 'ERROR: Your ReqPackages list seems to be problematic.';
|
||||
put 'ERROR- Check the description.sas file.';
|
||||
put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.';
|
||||
put 'ERROR- "Package1 (X.X)", "Package2 (Y.Y)", "Package3 (Z.Z)"';
|
||||
put 'ERROR- Provided value is:';
|
||||
length R $ 32767;
|
||||
R = symget('packageReqPackages');
|
||||
put 'ERROR- ' R;
|
||||
end;
|
||||
else
|
||||
rc = dosubl('title; options nonotes nosource ps=max ls=66 nodate nonumber nostimer;
|
||||
data _null_;
|
||||
length rq $ 64; put "ReqPackages:";
|
||||
do rq = &packageReqPackages.;
|
||||
put "- " rq;
|
||||
end;
|
||||
run;');
|
||||
run;
|
||||
/* turn on the original value of the note about quoted string length */
|
||||
options &qlenmax_fstimer_tmp.;
|
||||
%if &tryExcept. %then %abort;
|
||||
%end;
|
||||
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
@@ -1327,6 +1499,11 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
|
||||
%abort;
|
||||
%end;
|
||||
|
||||
|
||||
%local qlenmax_fstimer_tmp;
|
||||
%let qlenmax_fstimer_tmp = %sysfunc(getoption(quotelenmax)) %sysfunc(getoption(stimer)) %sysfunc(getoption(fullstimer));
|
||||
options NOquotelenmax NOstimer NOfullstimer;
|
||||
|
||||
/* generate package fileref with MD5 to allow
|
||||
different file reference for each package
|
||||
while loading package with %loadPackage() macro
|
||||
@@ -1493,6 +1670,9 @@ DESCRIPTION END:
|
||||
|
||||
/* collect the data */
|
||||
data &filesWithCodes.;
|
||||
putlog "NOTE: Generating content dataset: &filesWithCodes..";
|
||||
putlog "NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
|
||||
putlog "NOTE- ";
|
||||
base = "&filesLocation.";
|
||||
length folder file lowcase_name $ 256 folderRef fileRef $ 8;
|
||||
drop lowcase_name;
|
||||
@@ -1557,6 +1737,11 @@ data &filesWithCodes.;
|
||||
end;
|
||||
stop;
|
||||
run;
|
||||
|
||||
%local notesSourceOptions;
|
||||
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
|
||||
options NOnotes NOsource;
|
||||
|
||||
proc sort data = &filesWithCodes.;
|
||||
by order type file;
|
||||
run;
|
||||
@@ -1582,8 +1767,13 @@ title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_.";
|
||||
proc print data = &filesWithCodes.(drop=base folderRef fileRef rc folderid _abort_ fileId);
|
||||
run;
|
||||
title;
|
||||
options ¬esSourceOptions.;
|
||||
|
||||
|
||||
/* packages description */
|
||||
%put NOTE: Preparing description file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
infile &_DESCR_.;
|
||||
file &zipReferrence.(description.sas) encoding = &packageEncoding.;
|
||||
@@ -1592,6 +1782,9 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* package license */
|
||||
%put NOTE: Preparing license file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
%if %sysfunc(fexist(&_LIC_.)) %then
|
||||
%do;
|
||||
data _null_;
|
||||
@@ -1632,6 +1825,9 @@ run;
|
||||
%end;
|
||||
|
||||
/* package metadata */
|
||||
%put NOTE: Preparing metadata file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
if 0 then set &filesWithCodes. nobs=NOBS;
|
||||
if NOBS = 0 then
|
||||
@@ -1677,6 +1873,9 @@ run;
|
||||
%ICEloadpackage(sqlinds)
|
||||
|
||||
*/
|
||||
%put NOTE: Preparing iceloadpackage file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
file &zipReferrence.(iceloadpackage.sas) encoding = &packageEncoding.;
|
||||
put " ";
|
||||
@@ -1727,6 +1926,9 @@ run;
|
||||
|
||||
|
||||
/* loading package files */
|
||||
%put NOTE: Preparing load file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
if NOBS = 0 then stop;
|
||||
|
||||
@@ -2079,6 +2281,9 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* to load lazydata */
|
||||
%put NOTE: Preparing "lazydata" file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
if NOBS = 0 then stop;
|
||||
|
||||
@@ -2133,6 +2338,9 @@ run;
|
||||
|
||||
|
||||
/* unloading package objects */
|
||||
%put NOTE: Preparing unload file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
/* break if no data */
|
||||
if NOBS = 0 then stop;
|
||||
@@ -2374,6 +2582,9 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* package preview, i.e. print out all content of the package files into the log */
|
||||
%put NOTE: Preparing preview file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
/* break if no data */
|
||||
if NOBS = 0 then stop;
|
||||
@@ -2485,6 +2696,9 @@ data _null_;
|
||||
run;
|
||||
|
||||
/* package help */
|
||||
%put NOTE: Preparing help file.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
data _null_;
|
||||
/* break if no data */
|
||||
if NOBS = 0 then stop;
|
||||
@@ -2555,7 +2769,7 @@ data _null_;
|
||||
put ' end ; ';
|
||||
%end;
|
||||
|
||||
put 'put "***"; put "* SAS package generated by generatePackage, version 20220420 *"; put "***";';
|
||||
put 'put "***"; put "* SAS package generated by generatePackage, version 20220930 *"; put "***";';
|
||||
|
||||
put 'run; ' /;
|
||||
|
||||
@@ -2694,7 +2908,7 @@ data _null_;
|
||||
call execute(' put Try= " File existence in ZIP verified as: " ex;');
|
||||
call execute(' end ;');
|
||||
|
||||
call execute(' if ex then put "File " pathname "copied into the package with return code: " rc;');
|
||||
call execute(' if ex then put "File " pathname "copied into the package with return code: " rc "(0 = success)";');
|
||||
call execute(' else do;');
|
||||
call execute(' put "ERROR: File " pathname "NOT copied into the package!" ;');
|
||||
call execute(' call symputX("createPackageContentStatus",1,"L");');
|
||||
@@ -2754,7 +2968,9 @@ data _null_;
|
||||
run;
|
||||
|
||||
options notes source;
|
||||
%put NOTE-;
|
||||
%put NOTE-######################################################;
|
||||
%put NOTE-;
|
||||
options ¬esSourceOptions.;
|
||||
/*
|
||||
proc sql;
|
||||
@@ -2768,23 +2984,31 @@ filename &zipReferrence. clear;
|
||||
/* create hash SHA256 id */
|
||||
%if %sysfunc(exist(sashelp.vfunc, VIEW)) %then
|
||||
%do;
|
||||
%put NOTE-;
|
||||
%put NOTE: Calculating SHA256 check sum.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
filename &zipReferrence. "&filesLocation./%lowcase(&packageName.).zip";
|
||||
filename &zipReferrence. list;
|
||||
%local notesSourceOptions;
|
||||
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
|
||||
options NOnotes NOsource;
|
||||
data _null_;
|
||||
set sashelp.vfunc(keep=fncname);
|
||||
where fncname = "HASHING_FILE";
|
||||
call execute('
|
||||
data the_SHA256_hash_id;
|
||||
SHA256 = HASHING_FILE("SHA256", "&zipReferrence.", 4);
|
||||
lable SHA256 = "The SHA256 hash digest for package &packageName.:";
|
||||
put SHA256=;
|
||||
label SHA256 = "The SHA256 hash digest for package &packageName.:";
|
||||
put / @7 SHA256= / " ";
|
||||
run;');
|
||||
call execute('proc print data = the_SHA256_hash_id noobs label; run;');
|
||||
stop;
|
||||
run;
|
||||
options ¬esSourceOptions.;
|
||||
filename &zipReferrence. clear;
|
||||
%end;
|
||||
/*+++++++++++++++++++++++*/
|
||||
/*-+++++++++++++++++++++++-*/
|
||||
|
||||
/* verify if there were errors while package content creation */
|
||||
%if %bquote(&createPackageContentStatus.) ne 0 %then
|
||||
@@ -2802,6 +3026,10 @@ filename &zipReferrence. clear;
|
||||
%end;
|
||||
|
||||
|
||||
%put NOTE-;
|
||||
%put NOTE: Running tests.;
|
||||
%put NOTE- ^^^^^^^^^^^^^^;
|
||||
%put NOTE-;
|
||||
/* in case the packages macrovariable is multi-directory the first directory will be selected */
|
||||
data _null_;
|
||||
call symputX("packages", dequote(kscanx(resolve(symget("packages")), 1, "()", "QS")) ,"L");
|
||||
@@ -2867,7 +3095,7 @@ run;
|
||||
filename sasroot "!SASROOT";
|
||||
%let SASROOT=%sysfunc(PATHNAME(sasroot));
|
||||
filename sasroot;
|
||||
%put *&SASROOT.*;
|
||||
%put NOTE: &=SASROOT.;
|
||||
%let SASEXE=&SASROOT./sas;
|
||||
%end;
|
||||
%else
|
||||
@@ -2877,8 +3105,8 @@ run;
|
||||
%do;
|
||||
%let SASROOT=%sysfunc(PATHNAME(sasroot));
|
||||
filename sasroot;
|
||||
%put *&SASROOT.*;
|
||||
%let SASEXE=&SASROOT./sas;
|
||||
%put NOTE: &=SASROOT.;
|
||||
%let SASEXE=&SASROOT./sas;
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
@@ -2901,29 +3129,31 @@ run;
|
||||
%GOTO NOTESTING;
|
||||
%end;
|
||||
|
||||
%put * Location of the SAS binary is: ;
|
||||
%put * &=SASEXE. ;
|
||||
%put NOTE: Location of the SAS binary is:;
|
||||
%put NOTE- &=SASEXE. ;
|
||||
%put ;
|
||||
|
||||
/* locate sas work */
|
||||
%let SASWORK=%sysfunc(GETOPTION(work));
|
||||
%put *&SASWORK.*;
|
||||
%put NOTE: &=SASWORK.;
|
||||
%put ;
|
||||
|
||||
/* location of the config file */
|
||||
%local SASCONFIG; /* by default a local macrovariable is empty, so no file would be pointed as a config file */
|
||||
|
||||
%if %Qupcase(&sascfgfile.) = DEF %then /* the DEF value points to the sasv9.cfg file in the sasroot directory */
|
||||
%if %Qupcase(&sascfgFile.) = DEF %then /* the DEF value points to the sasv9.cfg file in the sasroot directory */
|
||||
%do;
|
||||
%let SASCONFIG = -config ""&SASROOT./sasv9.cfg"";
|
||||
%put * The following SAS config file will be used:;
|
||||
%put * &SASCONFIG.;
|
||||
%put NOTE: The following SAS config file will be used:;
|
||||
%put NOTE- &=SASCONFIG.;
|
||||
%end;
|
||||
%else %if %superq(sascfgfile) NE %then /* nonempty path points to user defined config file */
|
||||
%else %if %superq(sascfgFile) NE %then /* non-empty path points to user defined config file */
|
||||
%do;
|
||||
%if %sysfunc(fileexist(&sascfgfile.)) %then
|
||||
%if %sysfunc(fileexist(&sascfgFile.)) %then
|
||||
%do;
|
||||
%let SASCONFIG = -config ""&SASCFGFILE."";
|
||||
%put * The following SAS config file will be used:;
|
||||
%put * &SASCONFIG.;
|
||||
%put NOTE: The following SAS config file will be used:;
|
||||
%put NOTE- &=SASCONFIG.;
|
||||
%end;
|
||||
%else
|
||||
%do;
|
||||
@@ -2952,8 +3182,10 @@ libname TESTWORK "&SASWORK./testwork_&testPackageTimesamp.";
|
||||
%local dirForTest dirForTestWork;
|
||||
%let dirForTest = %sysfunc(pathname(TEST));
|
||||
%let dirForTestWork = %sysfunc(pathname(TESTWORK));
|
||||
%put &=dirForTest.;
|
||||
%put &=dirForTestWork.;
|
||||
%put ;
|
||||
%put NOTE: &=dirForTest.;
|
||||
%put NOTE: &=dirForTestWork.;
|
||||
%put ;
|
||||
|
||||
/* remember location of sessions current directory */
|
||||
filename currdir ".";
|
||||
@@ -2966,14 +3198,14 @@ filename currdir list;
|
||||
%if %bquote(&packages.)= %then %let packages=&filesLocation.;
|
||||
%put NOTE- ;
|
||||
%put NOTE: The following location path for packages will be used during the testing:;
|
||||
%put *&packages.*;
|
||||
%put NOTE- &packages.;
|
||||
/* filename packages "&packages."; */
|
||||
/* filename packages list;*/
|
||||
|
||||
/* replace current dir with the temporary one for tests */
|
||||
%put NOTE- ;
|
||||
%put NOTE: changing current folder to:;
|
||||
%put *%sysfunc(DLGCDIR(&dirForTest.))*;
|
||||
%put NOTE: Changing current folder to:;
|
||||
%put NOTE- *%sysfunc(DLGCDIR(&dirForTest.))*;
|
||||
|
||||
|
||||
/* turn off the note about quoted string length */
|
||||
@@ -3102,13 +3334,14 @@ status=sasstat0
|
||||
WAIT
|
||||
;
|
||||
|
||||
%put %superq(STSK);
|
||||
%put NOTE: Systask:;
|
||||
%put NOTE- %superq(STSK);
|
||||
;
|
||||
%unquote(&STSK.);
|
||||
;
|
||||
|
||||
%let TESTRC_0 = &SYSRC.;
|
||||
%put *&=sasstat0.*&=TESTRC_0.*;
|
||||
%put NOTE: &=sasstat0. &=TESTRC_0.;
|
||||
%local notesSourceOptions;
|
||||
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
|
||||
options NOnotes NOsource;
|
||||
@@ -3121,20 +3354,20 @@ data _null_;
|
||||
input;
|
||||
if _INFILE_ =: 'WARNING:' then
|
||||
do;
|
||||
warning+1;
|
||||
warnings+1;
|
||||
put _N_= "**" _INFILE_;
|
||||
end;
|
||||
if _INFILE_ =: 'ERROR:' then
|
||||
do;
|
||||
error+1;
|
||||
errors+1;
|
||||
put _N_= "$$" _INFILE_;
|
||||
end;
|
||||
if EOF then
|
||||
do;
|
||||
put "##########################################################################" ;
|
||||
put (_ALL_) (=/);
|
||||
call symputX("TESTW_0", warning, "L");
|
||||
call symputX("TESTE_0", error, "L");
|
||||
put (_ALL_) (=/ "Number of ");
|
||||
call symputX("TESTW_0", warnings, "L");
|
||||
call symputX("TESTE_0", errors, "L");
|
||||
end;
|
||||
run;
|
||||
options ¬esSourceOptions.;
|
||||
@@ -3191,6 +3424,18 @@ data _null_;
|
||||
put '%loadpackage'"(&packageName.,";
|
||||
put " path=&filesLocation., lazyData=*)" /;
|
||||
|
||||
/* check if work should be deleted after test is done */
|
||||
delTestWork = input(symget('delTestWork'), ?? best32.);
|
||||
if not(delTestWork in (0 1)) then
|
||||
do;
|
||||
putlog "WARNING: [&sysmacroname.] The `delTestWork` parameter is invalid.";
|
||||
putlog "WARNING- [&sysmacroname.] Default value (1) is set.";
|
||||
delTestWork = 1;
|
||||
end;
|
||||
|
||||
if 0 = delTestWork then
|
||||
put "options NOWORKTERM;"/;
|
||||
|
||||
/*
|
||||
put "proc printto";
|
||||
put "; run;";
|
||||
@@ -3219,13 +3464,14 @@ status=sasstat&t.
|
||||
WAIT
|
||||
;
|
||||
|
||||
%put %superq(STSK);
|
||||
%put NOTE: Systask:;
|
||||
%put NOTE- %superq(STSK);
|
||||
;
|
||||
%unquote(&STSK.);
|
||||
;
|
||||
|
||||
%let TESTRC_&t = &SYSRC.;
|
||||
%put *sasstat&t.=&&sasstat&t.*TESTRC_&t=&&TESTRC_&t*;
|
||||
%put NOTE- sasstat&t.=&&sasstat&t. TESTRC_&t=&&TESTRC_&t;
|
||||
%local notesSourceOptions;
|
||||
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
|
||||
options NOnotes NOsource;
|
||||
@@ -3238,14 +3484,14 @@ data _null_;
|
||||
input;
|
||||
if _INFILE_ =: 'WARNING:' then
|
||||
do;
|
||||
warning+1;
|
||||
warnings+1;
|
||||
/*length warningline $ 1024;
|
||||
warningline = catx(',', strip(warningline), _N_);*/
|
||||
put _N_= "**" _INFILE_;
|
||||
end;
|
||||
if _INFILE_ =: 'ERROR:' then
|
||||
do;
|
||||
error+1;
|
||||
errors+1;
|
||||
/*length errorline $ 1024;
|
||||
errorline = catx(',', strip(errorline), _N_);*/
|
||||
put _N_= "$$" _INFILE_;
|
||||
@@ -3253,9 +3499,9 @@ data _null_;
|
||||
if EOF then
|
||||
do;
|
||||
put "##########################################################################" ;
|
||||
put (_ALL_) (=/);
|
||||
call symputX("TESTW_&t.", warning, "L");
|
||||
call symputX("TESTE_&t.", error, "L");
|
||||
put (_ALL_) (=/ "Number of ");
|
||||
call symputX("TESTW_&t.", warnings, "L");
|
||||
call symputX("TESTE_&t.", errors, "L");
|
||||
end;
|
||||
run;
|
||||
options ¬esSourceOptions.;
|
||||
@@ -3265,10 +3511,10 @@ data test.tests_summary;
|
||||
length testName $ 128;
|
||||
do _N_ = 0 to &numberOfTests.;
|
||||
testName = symget(cats("TEST_", _N_));
|
||||
systask = input(symget(cats("SASSTAT", _N_)), best32.);
|
||||
sysrc = input(symget(cats("TESTRC_", _N_)), best32.);
|
||||
error = input(symget(cats("TESTE_", _N_)), best32.);
|
||||
warning = input(symget(cats("TESTW_", _N_)), best32.);
|
||||
systask = coalesce(input(symget(cats("SASSTAT", _N_)), ?? best32.), -1);
|
||||
sysrc = coalesce(input(symget(cats("TESTRC_", _N_)), ?? best32.), -1);
|
||||
error = coalesce(input(symget(cats("TESTE_", _N_)), ?? best32.), -1);
|
||||
warning = coalesce(input(symget(cats("TESTW_", _N_)), ?? best32.), -1);
|
||||
output;
|
||||
end;
|
||||
run;
|
||||
@@ -3282,8 +3528,8 @@ title;
|
||||
|
||||
/*%put _local_;*/
|
||||
|
||||
%put *NOTE: changing current folder to:*;
|
||||
%put *%sysfunc(DLGCDIR(%sysfunc(pathname(currdir))))*;
|
||||
%put NOTE: changing current folder to:;
|
||||
%put NOTE- *%sysfunc(DLGCDIR(%sysfunc(pathname(currdir))))*;
|
||||
filename CURRDIR clear;
|
||||
|
||||
/* turn on the original value of the note about quoted string length */
|
||||
@@ -3296,6 +3542,11 @@ proc sql;
|
||||
drop table &filesWithCodes.;
|
||||
quit;
|
||||
|
||||
/* turn on the original value of the note about quoted string length */
|
||||
options &qlenmax_fstimer_tmp.;
|
||||
|
||||
|
||||
|
||||
%ENDofgeneratePackage:
|
||||
%mend generatePackage;
|
||||
|
||||
@@ -3363,10 +3614,11 @@ TODO: (in Polish)
|
||||
|
||||
/*** HELP END ***/
|
||||
|
||||
/*+loadPackageS+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro loadPackageS(
|
||||
packagesNames /* A comma separated list of packages name,
|
||||
packagesNames /* A comma separated list of packages names,
|
||||
e.g. myPackage, myPackage1, myPackage2, myPackage3
|
||||
required and not null.
|
||||
Package version, in brackets behind a package name,
|
||||
@@ -3375,7 +3627,7 @@ TODO: (in Polish)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20220420. Run %loadPackages() for help info.'
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20220930. Run %loadPackages() for help info.'
|
||||
parmbuff
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
@@ -3391,7 +3643,7 @@ parmbuff
|
||||
%put ### This is short help information for the `loadPackageS` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20220420` #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -3463,6 +3715,7 @@ parmbuff
|
||||
%mend loadPackageS;
|
||||
|
||||
|
||||
/*+verifyPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro verifyPackage(
|
||||
@@ -3477,7 +3730,7 @@ parmbuff
|
||||
hashing_file() function, SAS 9.4M6 */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %verifyPackage() for help info.'
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20220930. Run %verifyPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -3492,7 +3745,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %
|
||||
%put ### This is short help information for the `verifyPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20220420` #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -3610,7 +3863,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %
|
||||
|
||||
if SHA256 = providedHash then
|
||||
do;
|
||||
put "NOTE: Package verification SUCCESFUL.";
|
||||
put "NOTE: Package verification SUCCESSFUL.";
|
||||
put "NOTE- Generated hash is EQUAL to the provided one.";
|
||||
end;
|
||||
else
|
||||
@@ -3624,7 +3877,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %
|
||||
%end;
|
||||
%else
|
||||
%put WARNING: Verification impossible! Minimum SAS version required for the process is 9.4M6. ;
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
/*-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist!;
|
||||
filename &_PackageFileref_. clear;
|
||||
@@ -3638,6 +3891,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %
|
||||
%mend verifyPackage;
|
||||
/**/
|
||||
|
||||
/*+previewPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro previewPackage(
|
||||
@@ -3662,7 +3916,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20220420. Run %
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to preview content of a SAS package, version 20220420. Run %previewPackage() for help info.'
|
||||
des = 'Macro to preview content of a SAS package, version 20220930. Run %previewPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -3677,7 +3931,7 @@ des = 'Macro to preview content of a SAS package, version 20220420. Run %preview
|
||||
%put ### This is short help information for the `previewPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get previwe of a SAS packages, version `20220420` #;
|
||||
%put # Macro to get previwe of a SAS packages, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -3796,7 +4050,7 @@ des = 'Macro to preview content of a SAS package, version 20220420. Run %preview
|
||||
%ENDofpreviewPackage:
|
||||
%mend previewPackage;
|
||||
|
||||
|
||||
/*+extendPackagesFileref+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro extendPackagesFileref(
|
||||
@@ -3804,7 +4058,7 @@ des = 'Macro to preview content of a SAS package, version 20220420. Run %preview
|
||||
when empty the "packages" value is used */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20220420. Run %extendPackagesFileref(HELP) for help info.'
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20220930. Run %extendPackagesFileref(HELP) for help info.'
|
||||
;
|
||||
|
||||
%if %QUPCASE(&packages.) = HELP %then
|
||||
@@ -3820,7 +4074,7 @@ des = 'Macro to list directories pointed by "packages" fileref, version 20220420
|
||||
%put ### This is short help information for the `extendPackagesFileref` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20220420` #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20220930` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
To get started with SAS Packages try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
|
||||
|
||||
## Available packages:
|
||||
Currently the following packages are available:
|
||||
For "backward compatibility"/historical point of view the following packages are available under the `./packages` directory.
|
||||
|
||||
Since *September 2022* the default location for packages is **SASPAC - the SAS Packages Archive** located under: [`https://github.com/SASPAC`](https://github.com/SASPAC) where each package is stored as a separate repository with historical versions too.
|
||||
|
||||
Packages:
|
||||
|
||||
---
|
||||
|
||||
@@ -18,7 +22,7 @@ data class;
|
||||
WH = weight + height;
|
||||
run;
|
||||
```
|
||||
SHA256 digest for SQLinDS: 701B69BE71B99792803BCE7718ED486259310FFB92E6D77ED1BC029D9CC67B60
|
||||
SHA256 digest for SQLinDS: 96D0EFE02DF1AE0D7D875A10CAF7EF63CDEF85DD0CF9418934BEFAF0C067D453
|
||||
|
||||
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/sqlinds.md "Documentation for SQLinDS")
|
||||
|
||||
@@ -59,7 +63,7 @@ data _null_;
|
||||
end;
|
||||
run;
|
||||
```
|
||||
SHA256 digest for DFA: 6B3FB0B06B47A7EF1BB004B483B0F39B8F553F7F16D02A7E24CDE388BBA704EA
|
||||
SHA256 digest for DFA: 5BFFCE78439E1CDDCBB15C95CD287AA4195BF64BB17DDB8FE374EC3535B4F491
|
||||
|
||||
[Documentation for DFA](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/dfa.md "Documentation for DFA")
|
||||
|
||||
@@ -84,13 +88,13 @@ SHA256 digest for DFA: 6B3FB0B06B47A7EF1BB004B483B0F39B8F553F7F16D02A7E24CDE388B
|
||||
which = 1:H:2
|
||||
);
|
||||
```
|
||||
SHA256 digest for macroArray: DF63B0E027827A82038F1C8422787A0BC569BA93104BA1778DB6DD088A5D255C
|
||||
SHA256 digest for macroArray: ED12BC96F8A4E9E7C4D651EC1E15479DB9B55D98B274B63C507ED842081F7AB7
|
||||
|
||||
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/macroarray.md "Documentation for macroArray")
|
||||
|
||||
---
|
||||
|
||||
- **BasePlus**\[1.15\] 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 +112,7 @@ format x bool.;
|
||||
|
||||
%zipLibrary(sashelp,libOut=work)
|
||||
```
|
||||
SHA256 digest for BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D85B0B2DEDE4E9
|
||||
SHA256 digest for BasePlus: 56B260350FEB7D5118F581B9EFD1B9CE1F0298DCB9A4C000A7654E2FF3F0298C
|
||||
|
||||
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/baseplus.md "Documentation for BasePlus")
|
||||
|
||||
@@ -119,14 +123,14 @@ SHA256 digest for BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D8
|
||||
The dataset with functions can be shared between different operating systems
|
||||
and allows to generate macros on site without showing their code.
|
||||
|
||||
SHA256 digest for GSM: E6E2A6214EE7DC6E06AA76916A68B216DD7665184E63CF2C01F487A038E71B09
|
||||
SHA256 digest for GSM: 2AEBC150FBA99A4AAB0265A21C57E89200BFD96B633B898F32743D1C8831A159
|
||||
|
||||
[Documentation for GSM](https://github.com/yabwon/SAS_PACKAGES/blob/main/packages/gsm.md "Documentation for GSM")
|
||||
|
||||
---
|
||||
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA). Development of this package is currently on hold.
|
||||
|
||||
SHA256 digest for dynMacroArray: 7DA9BFDED37C18C4FB5BD7579A81A4B2578EEEF1546D1A3AB5C80DE07C88A615
|
||||
SHA256 digest for dynMacroArray: D7E0B8F85C05EBF8622204E0D2F3E990D48D0A9B3911051C3AD44DC98954DDCF
|
||||
|
||||
---
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
/* 20220830 */
|
||||
BasePlus: 56B260350FEB7D5118F581B9EFD1B9CE1F0298DCB9A4C000A7654E2FF3F0298C
|
||||
DFA: 5BFFCE78439E1CDDCBB15C95CD287AA4195BF64BB17DDB8FE374EC3535B4F491
|
||||
dynMacroArray: D7E0B8F85C05EBF8622204E0D2F3E990D48D0A9B3911051C3AD44DC98954DDCF
|
||||
GSM: 2AEBC150FBA99A4AAB0265A21C57E89200BFD96B633B898F32743D1C8831A159
|
||||
macroArray: ED12BC96F8A4E9E7C4D651EC1E15479DB9B55D98B274B63C507ED842081F7AB7
|
||||
SQLinDS: 96D0EFE02DF1AE0D7D875A10CAF7EF63CDEF85DD0CF9418934BEFAF0C067D453
|
||||
|
||||
/* 20220511 */
|
||||
BasePlus: 619D4B2562F1D9E42C9C5DCB326E8F4D6A020B5D0CEE29A6174F65F8E1B0E7BD
|
||||
|
||||
/* 20220509 */
|
||||
BasePlus: 4CD3926B9842925C86B80B5B47B47BEA1FB9707826B545B9B4D52AE97BC3617E
|
||||
|
||||
/* 20220508 */
|
||||
BasePlus: 0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D85B0B2DEDE4E9
|
||||
|
||||
|
||||
@@ -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.15] <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*
|
||||
*SAS package generated by generatePackage, version 20220830*
|
||||
|
||||
The SHA256 hash digest for package BasePlus:
|
||||
`0331C673052D5221DA98C5CC93295634D8A0BC62C7D2FEF9D0D85B0B2DEDE4E9`
|
||||
`56B260350FEB7D5118F581B9EFD1B9CE1F0298DCB9A4C000A7654E2FF3F0298C`
|
||||
|
||||
---
|
||||
# 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:
|
||||
@@ -3593,23 +3599,6 @@ The `%LDSN()` macro executes like a pure macro code.
|
||||
`%ldsn(work.test)`, `%ldsn( work.test)`, `%ldsn(work.test )`,
|
||||
`%ldsn(work .test)`, `%ldsn(work. test)`, `%ldsn(work . test)`.
|
||||
|
||||
- if the user want to add an extra suffix to the dataset the `%ldsn()` macro
|
||||
**has** to be wrapped inside the `%unquote()` macro function.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
data
|
||||
%unquote(%LDSN(WORK.some strange! DS name))_1
|
||||
%unquote(%LDSN(WORK.some strange! DS name))_2
|
||||
;
|
||||
set sashelp.class;
|
||||
|
||||
if SEX="M" then output %unquote(%LDSN(WORK.some strange! DS name))_1;
|
||||
else output %unquote(%LDSN(WORK.some strange! DS name))_2;
|
||||
run;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The reason for this is a "bug" like behaviour of SAS tokenizer/macroprocesor.
|
||||
See the following SAS-L discussion thread:
|
||||
`https://listserv.uga.edu/scripts/wa-UGA.exe?A2=SAS-L;4b2bcf80.2205A&S=`
|
||||
|
||||
- macro calls of the form:
|
||||
`data %LDSN(); run;`, `data %LDSN( ); run;`, `data %LDSN( . ); run;` or even
|
||||
`data %LDSN( . (keep=x)); run;` are resolved to empty string, so the result is
|
||||
@@ -3624,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.**
|
||||
@@ -3645,12 +3640,170 @@ 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()` macro works differently than the `%LDSN()` macro.
|
||||
|
||||
The `%LDSN()` macro assumes that *both* libname and dataset options *are*
|
||||
be passed as elements **inside** the macro argument, together with the data set name. 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()` macro, in contrary, assumes that both libname and dataset options are
|
||||
passed **outside** the macro parameter, 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 overcomes some limitations the LDSN has.
|
||||
|
||||
The **additional** feature of the `%LDSNM()` is that when the macro is called,
|
||||
a global macrovariable is created.
|
||||
The macro variable name is the text of the hashed data set name.
|
||||
The macro variable value is the text of the unhashed data set name (i.e. 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 macro variable with name `DSN_BF1F8C4D6495B34A_` and 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 considered as *"only dataset name"*, i.e. the macro does not
|
||||
assume it contains library as prefix or data set options as suffix.
|
||||
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.
|
||||
Supported by LVarNmLab() macro function which allows to remember "user names" in labels.
|
||||
|
||||
The motivation for the macro was similar one as for the LDSN() macro.
|
||||
The motivation for the macro was similar to that for the LDSN() macro.
|
||||
|
||||
---
|
||||
|
||||
@@ -3671,23 +3824,6 @@ The `%LVarNm()` macro executes like a pure macro code.
|
||||
e.g. the following will give the same hash digest:
|
||||
`%LVarNm(test)`, `%LVarNm( test)`, `%LVarNm(test )`.
|
||||
|
||||
- if the user want to add an extra suffix to the variable,
|
||||
e.g. to get a numerical suffix, the `%LVarNm()` macro
|
||||
**has** to be wrapped inside the `%unquote()` macro function.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
data test4;
|
||||
array X[*] %unquote(%LVarNm(some strange! name))_0 - %unquote(%LVarNm(some strange! name))_10;
|
||||
|
||||
do i = lbound(X) to hbound(X);
|
||||
X[i] = 2**(i-1);
|
||||
put X[i]=;
|
||||
end;
|
||||
run;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The reason for this is a "bug" like behaviour of SAS tokenizer/macroprocesor.
|
||||
See the following SAS-L discussion thread:
|
||||
`https://listserv.uga.edu/scripts/wa-UGA.exe?A2=SAS-L;4b2bcf80.2205A&S=`
|
||||
|
||||
### SYNTAX: ###################################################################
|
||||
|
||||
The basic syntax is the following, the `<...>` means optional parameters:
|
||||
@@ -3700,7 +3836,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
|
||||
---
|
||||
|
||||
|
||||
### EXAMPLES AND USECASES: ####################################################
|
||||
### EXAMPLES AND USE CASES: ####################################################
|
||||
|
||||
**EXAMPLE 1.**
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
@@ -3751,7 +3887,7 @@ run;
|
||||
**EXAMPLE 4.**
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
data test4;
|
||||
array X[*] %unquote(%LVarNm(some strange! name))_0 - %unquote(%LVarNm(some strange! name))_10;
|
||||
array X[*] %LVarNm(some strange! name)_0 - %LVarNm(some strange! name)_10;
|
||||
|
||||
do i = lbound(X) to hbound(X);
|
||||
X[i] = 2**(i-1);
|
||||
|
||||
Binary file not shown.
@@ -52,10 +52,10 @@ Package contains:
|
||||
12. exec generatearrays
|
||||
13. clean generatearrays
|
||||
|
||||
*SAS package generated by generatePackage, version 20220420*
|
||||
*SAS package generated by generatePackage, version 20220830*
|
||||
|
||||
The SHA256 hash digest for package BasePlus:
|
||||
`6B3FB0B06B47A7EF1BB004B483B0F39B8F553F7F16D02A7E24CDE388BBA704EA`
|
||||
`5BFFCE78439E1CDDCBB15C95CD287AA4195BF64BB17DDB8FE374EC3535B4F491`
|
||||
|
||||
---
|
||||
# Content description ############################################################################################
|
||||
|
||||
BIN
packages/dfa.zip
BIN
packages/dfa.zip
Binary file not shown.
Binary file not shown.
@@ -91,10 +91,10 @@ Package contains:
|
||||
Required SAS Components:
|
||||
`Base SAS Software`
|
||||
|
||||
* SAS package generated by generatePackage, version 20220420 *
|
||||
* SAS package generated by generatePackage, version 20220830 *
|
||||
|
||||
The SHA256 hash digest for package GSM:
|
||||
`E6E2A6214EE7DC6E06AA76916A68B216DD7665184E63CF2C01F487A038E71B09`
|
||||
`2AEBC150FBA99A4AAB0265A21C57E89200BFD96B633B898F32743D1C8831A159`
|
||||
|
||||
|
||||
## >>> `%GSM()` macro: <<< <a name="gsm-macro"></a> #######################
|
||||
|
||||
BIN
packages/gsm.zip
BIN
packages/gsm.zip
Binary file not shown.
@@ -75,10 +75,10 @@ Package contains:
|
||||
Required SAS Components:
|
||||
*Base SAS Software*
|
||||
|
||||
*SAS package generated by generatePackage, version 20220420.*
|
||||
*SAS package generated by generatePackage, version 20220830.*
|
||||
|
||||
The SHA256 hash digest for package macroArray:
|
||||
`DF63B0E027827A82038F1C8422787A0BC569BA93104BA1778DB6DD088A5D255C`
|
||||
`ED12BC96F8A4E9E7C4D651EC1E15479DB9B55D98B274B63C507ED842081F7AB7`
|
||||
|
||||
---
|
||||
# Content description ############################################################################################
|
||||
|
||||
Binary file not shown.
@@ -46,10 +46,10 @@ Package contains:
|
||||
Required SAS Components:
|
||||
*Base SAS Software*
|
||||
|
||||
*SAS package generated by generatePackage, version 20220420*
|
||||
*SAS package generated by generatePackage, version 20220830*
|
||||
|
||||
The SHA256 hash digest for package SQLinDS:
|
||||
`701B69BE71B99792803BCE7718ED486259310FFB92E6D77ED1BC029D9CC67B60`
|
||||
`96D0EFE02DF1AE0D7D875A10CAF7EF63CDEF85DD0CF9418934BEFAF0C067D453`
|
||||
|
||||
---
|
||||
# Content description ############################################################################################
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user