mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-05 06:10:05 +00:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ecccacdce | ||
|
|
b274d0dcda | ||
|
|
3881f936ca | ||
|
|
d53f622776 | ||
|
|
8c584c8030 | ||
|
|
5c640cba21 | ||
|
|
73e8d10200 | ||
|
|
93904a03cb | ||
|
|
55aaa8748c | ||
|
|
63f849dd24 | ||
|
|
ef5864dc88 | ||
|
|
c10851e9ef | ||
|
|
10994721b4 | ||
|
|
5461c587be | ||
|
|
e97c8e31ad | ||
|
|
16d55d7dcb | ||
|
|
c54ef20fac | ||
|
|
be2af5883a | ||
|
|
b867ed4309 | ||
|
|
6a53bbe50a | ||
|
|
3e44e6b8ae | ||
|
|
f3f7a3896a | ||
|
|
7491d42378 | ||
|
|
16a20907af | ||
|
|
f3107f0db3 | ||
|
|
0ca3eac3c9 | ||
|
|
4eac2a0fea | ||
|
|
ad81e0cb0e |
36
README.md
36
README.md
@@ -6,7 +6,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.
|
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 `20200811`.
|
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20201001`**.
|
||||||
|
|
||||||
To get started with SAS Packages try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/master/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
|
To get started with SAS Packages try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/master/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
|
||||||
|
|
||||||
@@ -65,30 +65,46 @@ To create your own package:
|
|||||||
## Available packages:
|
## Available packages:
|
||||||
Currently the following packages are available (see the `./packages` directory):
|
Currently the following packages are available (see the `./packages` directory):
|
||||||
|
|
||||||
- **SQLinDS**\[2.1\], 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.
|
- **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.
|
||||||
```
|
```
|
||||||
data class;
|
data class;
|
||||||
set %SQL(select * from sashelp.class order by age);
|
set %SQL(select * from sashelp.class order by age);
|
||||||
run;
|
run;
|
||||||
```
|
```
|
||||||
|
SHA256 digest for SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
|
||||||
|
|
||||||
|
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/sqlinds.md "Documentation for SQLinDS")
|
||||||
|
|
||||||
- **DFA** (Dynamic Function Arrays)\[0.2\], 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.
|
- **DFA** (Dynamic Function Arrays)\[0.2\], 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.
|
||||||
- **macroArray**\[0.3\], implementation of an array concept in a macrolanguage, e.g.
|
|
||||||
|
SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA
|
||||||
|
|
||||||
|
|
||||||
|
- **macroArray**\[0.5\], implementation of an array concept in a macrolanguage, e.g.
|
||||||
```
|
```
|
||||||
%array(ABC[17] (111:127), macarray=Y);
|
%array(ABC[17] (111:127), macarray=Y);
|
||||||
|
|
||||||
|
%macro test();
|
||||||
%do i = 1 %to 17;
|
%do i = 1 %to 17;
|
||||||
%put &i.) %ABC(&i.);
|
%put &i.) %ABC(&i.);
|
||||||
%end;
|
%end;
|
||||||
|
%mend;
|
||||||
|
%test()
|
||||||
|
|
||||||
%let %ABC(13,i) = 999; /* i = insert */
|
%let %ABC(13,i) = 99999; /* i = insert */
|
||||||
|
|
||||||
%do i = 1 %to 17;
|
%do_over(ABC, phrase=%nrstr(
|
||||||
%put &i.) %ABC(&i.);
|
%put &_i_.%) %ABC(&_i_.);
|
||||||
%end;
|
),
|
||||||
|
which = 1:H:2
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
|
||||||
|
|
||||||
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
|
||||||
|
|
||||||
|
|
||||||
|
- **BasePlus**\[0.62\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||||
```
|
```
|
||||||
call arrMissToRight(myArray);
|
call arrMissToRight(myArray);
|
||||||
call arrFillMiss(17, myArray);
|
call arrFillMiss(17, myArray);
|
||||||
@@ -102,7 +118,11 @@ format x bool.;
|
|||||||
|
|
||||||
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
||||||
```
|
```
|
||||||
|
SHA256 digest for BasePlus: 278621A6D8BBBB791DEA4C215D4261F2CB8F8B76B1397F7FA9B2E4219E77CB5A
|
||||||
|
|
||||||
|
|
||||||
- **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)
|
||||||
|
|
||||||
|
SHA256 digest for dynMacroArray: 066186B94B2976167C797C6A6E6217E361E8DEB10F2AB81906E0A325E5243084
|
||||||
|
|
||||||
### ======
|
### ======
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
529
SPF/SPFinit.sas
529
SPF/SPFinit.sas
@@ -42,7 +42,7 @@
|
|||||||
- to unload, or
|
- to unload, or
|
||||||
- to generate SAS packages.
|
- to generate SAS packages.
|
||||||
|
|
||||||
Version 20200811.
|
Version 20201001.
|
||||||
See examples below.
|
See examples below.
|
||||||
|
|
||||||
A SAS package is a zip file containing a group of files
|
A SAS package is a zip file containing a group of files
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
*/
|
*/
|
||||||
)/secure
|
)/secure
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help info.'
|
des = 'Macro to load SAS package, version 20201001. Run %loadPackage() for help info.'
|
||||||
;
|
;
|
||||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||||
%do;
|
%do;
|
||||||
@@ -96,7 +96,7 @@ des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help
|
|||||||
%put # This is short help information for the loadPackage macro #;
|
%put # This is short help information for the loadPackage macro #;
|
||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to load SAS packages, version 20200811 #;
|
%put # Macro to load SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -165,7 +165,7 @@ des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help
|
|||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDofloadPackage;
|
||||||
%end;
|
%end;
|
||||||
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
||||||
%let ls_tmp = %sysfunc(getoption(ls));
|
%let ls_tmp = %sysfunc(getoption(ls));
|
||||||
@@ -191,9 +191,12 @@ des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help
|
|||||||
/* test if required version of package is "good enough" */
|
/* test if required version of package is "good enough" */
|
||||||
%if %sysevalf(&requiredVersion. > &packageVersion.) %then
|
%if %sysevalf(&requiredVersion. > &packageVersion.) %then
|
||||||
%do;
|
%do;
|
||||||
%put ERROR: Required version is &requiredVersion.;
|
%put ERROR: Package &packageName. will not be loaded!;
|
||||||
|
%put ERROR- Required version is &requiredVersion.;
|
||||||
%put ERROR- Provided version is &packageVersion.;
|
%put ERROR- Provided version is &packageVersion.;
|
||||||
%ABORT;
|
%put ERROR- Verify installed version of the package.;
|
||||||
|
%put ERROR- ;
|
||||||
|
%GOTO WrongVersionOFPackage; /*%RETURN;*/
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||||
@@ -213,12 +216,15 @@ des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help
|
|||||||
%end;
|
%end;
|
||||||
|
|
||||||
%end;
|
%end;
|
||||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist;
|
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||||
filename &_PackageFileref_. clear;
|
filename &_PackageFileref_. clear;
|
||||||
|
|
||||||
|
%WrongVersionOFPackage:
|
||||||
options ls = &ls_tmp. ps = &ps_tmp.
|
options ls = &ls_tmp. ps = &ps_tmp.
|
||||||
¬es_tmp. &source_tmp.
|
¬es_tmp. &source_tmp.
|
||||||
&stimer_tmp. &fullstimer_tmp.
|
&stimer_tmp. &fullstimer_tmp.
|
||||||
msglevel=&msglevel_tmp.;
|
msglevel=&msglevel_tmp.;
|
||||||
|
%ENDofloadPackage:
|
||||||
%mend loadPackage;
|
%mend loadPackage;
|
||||||
|
|
||||||
/*** HELP START ***/
|
/*** HELP START ***/
|
||||||
@@ -242,7 +248,7 @@ des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help
|
|||||||
*/
|
*/
|
||||||
)/secure
|
)/secure
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for help info.'
|
des = 'Macro to unload SAS package, version 20201001. Run %unloadPackage() for help info.'
|
||||||
;
|
;
|
||||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||||
%do;
|
%do;
|
||||||
@@ -257,7 +263,7 @@ des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for h
|
|||||||
%put # This is short help information for the unloadPackage macro #;
|
%put # This is short help information for the unloadPackage macro #;
|
||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to unload SAS packages, version 20200811 #;
|
%put # Macro to unload SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -317,7 +323,7 @@ des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for h
|
|||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDofunloadPackage;
|
||||||
%end;
|
%end;
|
||||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||||
%let ls_tmp = %sysfunc(getoption(ls));
|
%let ls_tmp = %sysfunc(getoption(ls));
|
||||||
@@ -346,9 +352,10 @@ des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for h
|
|||||||
;
|
;
|
||||||
%include &_PackageFileref_.(unload.sas) / &source2.;
|
%include &_PackageFileref_.(unload.sas) / &source2.;
|
||||||
%end;
|
%end;
|
||||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist;
|
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||||
filename &_PackageFileref_. clear;
|
filename &_PackageFileref_. clear;
|
||||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
||||||
|
%ENDofunloadPackage:
|
||||||
%mend unloadPackage;
|
%mend unloadPackage;
|
||||||
|
|
||||||
/*** HELP START ***/
|
/*** HELP START ***/
|
||||||
@@ -376,7 +383,7 @@ des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for h
|
|||||||
*/
|
*/
|
||||||
)/secure
|
)/secure
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
des = 'Macro to get help about SAS package, version 20200811. Run %helpPackage() for help info.'
|
des = 'Macro to get help about SAS package, version 20201001. Run %helpPackage() for help info.'
|
||||||
;
|
;
|
||||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||||
%do;
|
%do;
|
||||||
@@ -391,7 +398,7 @@ des = 'Macro to get help about SAS package, version 20200811. Run %helpPackage()
|
|||||||
%put # This is short help information for the helpPackage macro #;
|
%put # This is short help information for the helpPackage macro #;
|
||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to get help about SAS packages, version 20200811 #;
|
%put # Macro to get help about SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -456,7 +463,7 @@ des = 'Macro to get help about SAS package, version 20200811. Run %helpPackage()
|
|||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDofhelpPackage;
|
||||||
%end;
|
%end;
|
||||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||||
%let ls_tmp = %sysfunc(getoption(ls));
|
%let ls_tmp = %sysfunc(getoption(ls));
|
||||||
@@ -485,9 +492,10 @@ des = 'Macro to get help about SAS package, version 20200811. Run %helpPackage()
|
|||||||
;
|
;
|
||||||
%include &_PackageFileref_.(help.sas) / &source2.;
|
%include &_PackageFileref_.(help.sas) / &source2.;
|
||||||
%end;
|
%end;
|
||||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist;
|
%else %put ERROR:[&sysmacroname] File "&path./&packageName..&zip." does not exist!;
|
||||||
filename &_PackageFileref_. clear;
|
filename &_PackageFileref_. clear;
|
||||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp. msglevel = &msglevel_tmp.;
|
||||||
|
%ENDofhelpPackage:
|
||||||
%mend helpPackage;
|
%mend helpPackage;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -496,7 +504,7 @@ TODO:
|
|||||||
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
|
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Macros to install SAS packages, version 20200811 */
|
/* Macros to install SAS packages, version 20201001 */
|
||||||
/* A SAS package is a zip file containing a group of files
|
/* A SAS package is a zip file containing a group of files
|
||||||
with SAS code (macros, functions, data steps generating
|
with SAS code (macros, functions, data steps generating
|
||||||
data, etc.) wrapped up together and %INCLUDEed by
|
data, etc.) wrapped up together and %INCLUDEed by
|
||||||
@@ -505,15 +513,16 @@ TODO:
|
|||||||
|
|
||||||
/*** HELP START ***/
|
/*** HELP START ***/
|
||||||
%macro installPackage(
|
%macro installPackage(
|
||||||
packageName /* package name, without the zip extension */
|
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 */
|
, sourcePath = /* location of the package, e.g. "www.some.page/", mind the "/" at the end */
|
||||||
, replace = 1 /* 1 = replace if the package already exist, 0 = otherwise */
|
, replace = 1 /* 1 = replace if the package already exist, 0 = otherwise */
|
||||||
)
|
)
|
||||||
/secure
|
/secure
|
||||||
|
minoperator
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
des = 'Macro to install SAS package, version 20200811. Run %%installPackage() for help info.'
|
des = 'Macro to install SAS package, version 20201001. Run %%installPackage() for help info.'
|
||||||
;
|
;
|
||||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||||
%do;
|
%do;
|
||||||
%local options_tmp ;
|
%local options_tmp ;
|
||||||
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
|
||||||
@@ -522,11 +531,11 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
;
|
;
|
||||||
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
options NOnotes NOsource ls=MAX ps=MAX msglevel=N;
|
||||||
%put ;
|
%put ;
|
||||||
%put ########################################################################################;
|
%put #########################################################################################;
|
||||||
%put # This is short help information for the installPackage macro #;
|
%put # This is short help information for the installPackage macro #;
|
||||||
%put ########################################################################################;
|
%put #########################################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to install SAS packages, version 20200811 #;
|
%put # Macro to install SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -539,25 +548,30 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
%put # #;
|
%put # #;
|
||||||
%put # Parameters: #;
|
%put # Parameters: #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # packageName Name of a package, e.g. myPackage, #;
|
%put # 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 # Required and not null, default use case: #;
|
||||||
%put # %nrstr(%%installPackage(myPackage)). #;
|
%put # %nrstr(%%installPackage(myPackage1 myPackage2)). #;
|
||||||
%put # If empty displays this help information. #;
|
%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 # #;
|
||||||
%put # sourcePath= Location of the package, e.g. "www.some.web.page/" #;
|
%put # sourcePath= Location of the package, e.g. "www.some.web.page/" #;
|
||||||
%put # Mind the "/" at the end of the path! #;
|
%put # Mind the "/" at the end of the path! #;
|
||||||
%put # Current default location: #;
|
%put # Current default location for packages is: #;
|
||||||
%put # https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/ #;
|
%put # https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/ #;
|
||||||
|
%put # Current default location for the framework is: #;
|
||||||
|
%put # https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/SPF/ #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # replace= With default value of 1 it causes existing package file #;
|
%put # replace= With default value of 1 it causes existing package file #;
|
||||||
%put # to be replaceed by new downloaded file. #;
|
%put # to be replaceed by new downloaded file. #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put ########################################################################################;
|
%put #########################################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Visit: https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation #;
|
%put # Visit: https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation #;
|
||||||
%put # to learn more. #;
|
%put # to learn more. #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Example ##############################################################################;
|
%put # Example ###############################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Enabling the SAS Package Framework #;
|
%put # Enabling the SAS Package Framework #;
|
||||||
%put # from the local directory and installing & loading #;
|
%put # from the local directory and installing & loading #;
|
||||||
@@ -576,10 +590,10 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
|
%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 %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
|
||||||
%put ;
|
%put ;
|
||||||
%put ########################################################################################;
|
%put #########################################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDofinstallPackage;
|
||||||
%end;
|
%end;
|
||||||
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
||||||
%let ls_tmp = %sysfunc(getoption(ls));
|
%let ls_tmp = %sysfunc(getoption(ls));
|
||||||
@@ -591,12 +605,6 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
%let msglevel_tmp = %sysfunc(getoption(msglevel));
|
||||||
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N;
|
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N;
|
||||||
|
|
||||||
%local in out;
|
|
||||||
%let in = i%sysfunc(md5(&packageName.),hex7.);
|
|
||||||
%let out = o%sysfunc(md5(&packageName.),hex7.);
|
|
||||||
|
|
||||||
/*options MSGLEVEL=i;*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reference:
|
Reference:
|
||||||
https://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhere/
|
https://blogs.sas.com/content/sasdummy/2011/06/17/how-to-use-sas-data-step-to-copy-a-file-from-anywhere/
|
||||||
@@ -606,8 +614,35 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
%do;
|
%do;
|
||||||
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/;
|
%let sourcePath = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%local i;
|
||||||
|
%do i = 1 %to %sysfunc(countw(&packagesNames., , S));
|
||||||
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||||
|
%local packageName;
|
||||||
|
%let packageName = %scan(&packagesNames., &i., , S);
|
||||||
|
|
||||||
|
%put ;
|
||||||
|
%put *** %lowcase(&packageName.) start *****************************************;
|
||||||
|
%local in out;
|
||||||
|
%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
|
||||||
|
"https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/SPF/SPFinit.sas"
|
||||||
|
recfm=N lrecl=1;
|
||||||
|
filename &out
|
||||||
|
"%sysfunc(pathname(packages))/SPFinit.sas"
|
||||||
|
recfm=N lrecl=1;
|
||||||
|
%end;
|
||||||
|
%else
|
||||||
|
%do;
|
||||||
filename &in URL "&sourcePath.%lowcase(&packageName.).zip" recfm=N lrecl=1;
|
filename &in URL "&sourcePath.%lowcase(&packageName.).zip" recfm=N lrecl=1;
|
||||||
filename &out "%sysfunc(pathname(packages))/%lowcase(&packageName.).zip" recfm=N lrecl=1;
|
filename &out "%sysfunc(pathname(packages))/%lowcase(&packageName.).zip" recfm=N lrecl=1;
|
||||||
|
%end;
|
||||||
/*
|
/*
|
||||||
filename in list;
|
filename in list;
|
||||||
filename out list;
|
filename out list;
|
||||||
@@ -639,8 +674,6 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
rc = FCLOSE(filein);
|
rc = FCLOSE(filein);
|
||||||
put;
|
put;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if FEXIST("&out") = 0 then
|
if FEXIST("&out") = 0 then
|
||||||
do;
|
do;
|
||||||
put @2 "Installing the &packageName. package.";
|
put @2 "Installing the &packageName. package.";
|
||||||
@@ -664,15 +697,19 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
put @2 "Done with return code " rc=;
|
put @2 "Done with return code " rc= "(zero = success)";
|
||||||
run;
|
run;
|
||||||
|
|
||||||
filename &in clear;
|
filename &in clear;
|
||||||
filename &out clear;
|
filename &out clear;
|
||||||
|
%put *** %lowcase(&packageName.) end *******************************************;
|
||||||
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||||
|
%end;
|
||||||
options ls = &ls_tmp. ps = &ps_tmp.
|
options ls = &ls_tmp. ps = &ps_tmp.
|
||||||
¬es_tmp. &source_tmp.
|
¬es_tmp. &source_tmp.
|
||||||
&stimer_tmp. &fullstimer_tmp.
|
&stimer_tmp. &fullstimer_tmp.
|
||||||
msglevel=&msglevel_tmp.;
|
msglevel=&msglevel_tmp.;
|
||||||
|
%ENDofinstallPackage:
|
||||||
%mend installPackage;
|
%mend installPackage;
|
||||||
|
|
||||||
/*** HELP START ***/
|
/*** HELP START ***/
|
||||||
@@ -790,7 +827,7 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
|
|
||||||
/* Macro to list SAS packages in packages folder.
|
/* Macro to list SAS packages in packages folder.
|
||||||
|
|
||||||
Version 20200811
|
Version 20201001
|
||||||
|
|
||||||
A SAS package is a zip file containing a group
|
A SAS package is a zip file containing a group
|
||||||
of SAS codes (macros, functions, data steps generating
|
of SAS codes (macros, functions, data steps generating
|
||||||
@@ -810,7 +847,7 @@ des = 'Macro to install SAS package, version 20200811. Run %%installPackage() fo
|
|||||||
|
|
||||||
|
|
||||||
%macro listPackages()/PARMBUFF
|
%macro listPackages()/PARMBUFF
|
||||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20200811.'
|
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20201001.'
|
||||||
;
|
;
|
||||||
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
||||||
%do;
|
%do;
|
||||||
@@ -825,7 +862,7 @@ des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HE
|
|||||||
%put # This is short help information for the listPackages macro #;
|
%put # This is short help information for the listPackages macro #;
|
||||||
%put ########################################################################################;
|
%put ########################################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to list available SAS packages, version 20200811 #;
|
%put # Macro to list available SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -863,7 +900,7 @@ des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HE
|
|||||||
%put ########################################################################################;
|
%put ########################################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDoflistPackages;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%local ls_tmp ps_tmp notes_tmp source_tmp filesWithCodes;
|
%local ls_tmp ps_tmp notes_tmp source_tmp filesWithCodes;
|
||||||
@@ -884,14 +921,14 @@ data _null_;
|
|||||||
stop;
|
stop;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
length folder file $ 256 folderRef fileRef $ 8;
|
length folder $ 64 file $ 1024 folderRef fileRef $ 8;
|
||||||
|
|
||||||
folderRef = "_%sysfunc(datetime(), hex6.)0";
|
folderRef = "_%sysfunc(datetime(), hex6.)0";
|
||||||
|
|
||||||
rc=filename(folderRef, base);
|
rc=filename(folderRef, base);
|
||||||
folderid=dopen(folderRef);
|
folderid=dopen(folderRef);
|
||||||
|
|
||||||
put;
|
putlog " ";
|
||||||
put "/*" 100*"+" ;
|
put "/*" 100*"+" ;
|
||||||
do i=1 to dnum(folderId); drop i;
|
do i=1 to dnum(folderId); drop i;
|
||||||
folder = dread(folderId, i);
|
folder = dread(folderId, i);
|
||||||
@@ -904,13 +941,24 @@ data _null_;
|
|||||||
if fileId = 0 and lowcase(scan(folder, -1, ".")) = 'zip' then
|
if fileId = 0 and lowcase(scan(folder, -1, ".")) = 'zip' then
|
||||||
do;
|
do;
|
||||||
file = catx('/',base, folder);
|
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;
|
length nn $ 96;
|
||||||
|
if (96-lengthn(file)) < 1 then
|
||||||
|
put " * " file;
|
||||||
|
else
|
||||||
|
do;
|
||||||
nn = repeat("*", (96-lengthn(file)));
|
nn = repeat("*", (96-lengthn(file)));
|
||||||
|
put " * " file nn;
|
||||||
|
end;
|
||||||
|
|
||||||
putlog " ";
|
infile _DUMMY_ ZIP FILEVAR=file member="description.sas" end=EOF;
|
||||||
put " * " file @; put nn /;
|
|
||||||
|
|
||||||
infile package ZIP FILEVAR=file member="description.sas" end=EOF;
|
|
||||||
|
|
||||||
do until(EOF);
|
do until(EOF);
|
||||||
input;
|
input;
|
||||||
@@ -922,12 +970,13 @@ data _null_;
|
|||||||
if upcase(strip(_INFILE_)) =: "DESCRIPTION START:" then leave;
|
if upcase(strip(_INFILE_)) =: "DESCRIPTION START:" then leave;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
rc = dclose(fileId);
|
rc = dclose(fileId);
|
||||||
rc = filename(fileRef);
|
rc = filename(fileRef);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
putlog " ";
|
putlog " * ";
|
||||||
put 100*"+" "*/";
|
put 100*"+" "*/";
|
||||||
rc = dclose(folderid);
|
rc = dclose(folderid);
|
||||||
rc = filename(folderRef);
|
rc = filename(folderRef);
|
||||||
@@ -935,6 +984,7 @@ data _null_;
|
|||||||
run;
|
run;
|
||||||
|
|
||||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||||
|
%ENDoflistPackages:
|
||||||
%mend listPackages;
|
%mend listPackages;
|
||||||
|
|
||||||
|
|
||||||
@@ -942,7 +992,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
|||||||
|
|
||||||
/* Macro to generate SAS packages.
|
/* Macro to generate SAS packages.
|
||||||
|
|
||||||
Version 20200811
|
Version 20201001
|
||||||
|
|
||||||
A SAS package is a zip file containing a group
|
A SAS package is a zip file containing a group
|
||||||
of SAS codes (macros, functions, data steps generating
|
of SAS codes (macros, functions, data steps generating
|
||||||
@@ -965,7 +1015,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
|||||||
dependencies in loading */
|
dependencies in loading */
|
||||||
)/secure
|
)/secure
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
des = 'Macro to generate SAS packages, version 20200811. Run %generatePackage() for help info.'
|
des = 'Macro to generate SAS packages, version 20201001. Run %generatePackage() for help info.'
|
||||||
;
|
;
|
||||||
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
|
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
|
||||||
%do;
|
%do;
|
||||||
@@ -980,7 +1030,7 @@ des = 'Macro to generate SAS packages, version 20200811. Run %generatePackage()
|
|||||||
%put # This is short help information for the generatePackage macro #;
|
%put # This is short help information for the generatePackage macro #;
|
||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # Macro to generate SAS packages, version 20200811 #;
|
%put # Macro to generate SAS packages, version 20201001 #;
|
||||||
%put # #;
|
%put # #;
|
||||||
%put # A SAS package is a zip file containing a group #;
|
%put # A SAS package is a zip file containing a group #;
|
||||||
%put # of SAS codes (macros, functions, data steps generating #;
|
%put # of SAS codes (macros, functions, data steps generating #;
|
||||||
@@ -1012,7 +1062,7 @@ des = 'Macro to generate SAS packages, version 20200811. Run %generatePackage()
|
|||||||
%put ###############################################################################;
|
%put ###############################################################################;
|
||||||
%put ;
|
%put ;
|
||||||
options &options_tmp.;
|
options &options_tmp.;
|
||||||
%RETURN;
|
%GOTO ENDofgeneratePackage;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_ _PackageFileref_;
|
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_ _PackageFileref_;
|
||||||
@@ -1695,7 +1745,7 @@ data _null_;
|
|||||||
*/
|
*/
|
||||||
/* test for supported types */
|
/* test for supported types */
|
||||||
if not (upcase(type) in:
|
if not (upcase(type) in:
|
||||||
('LIBNAME' 'MACRO' 'DATA' 'FUNCTION' /*'FUNCTIONS'*/ 'FORMAT' 'IMLMODULE' 'EXEC' 'CLEAN' 'LAZYDATA' 'TEST'))
|
('LIBNAME' 'MACRO' 'DATA' 'FUNCTION' /*'FUNCTIONS'*/ 'FORMAT' 'IMLMODULE' 'PROTO' 'EXEC' 'CLEAN' 'LAZYDATA' 'TEST'))
|
||||||
then
|
then
|
||||||
do;
|
do;
|
||||||
putlog 'WARNING: Type ' type 'is not yet supported.';
|
putlog 'WARNING: Type ' type 'is not yet supported.';
|
||||||
@@ -1718,11 +1768,15 @@ data _null_;
|
|||||||
put '%put NOTE- ;';
|
put '%put NOTE- ;';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
/* HEADERS for IML and FCMP */
|
/* HEADERS for IML, FCMP, and PROTO */
|
||||||
if 1 = FIRST.type and upcase(type)='FUNCTIONS' then /* header, for multiple functions in one FCMP run */
|
if 1 = FIRST.type and upcase(type)='FUNCTIONS' then /* header, for multiple functions in one FCMP run */
|
||||||
do;
|
do;
|
||||||
put "proc fcmp outlib = work.%lowcase(&packageName.fcmp).package; ";
|
put "proc fcmp outlib = work.%lowcase(&packageName.fcmp).package; ";
|
||||||
end;
|
end;
|
||||||
|
if 1 = FIRST.type and upcase(type)='PROTO' then /* header, for multiple functions in one FCMP run */
|
||||||
|
do;
|
||||||
|
put "proc proto package = work.%lowcase(&packageName.proto).package; ";
|
||||||
|
end;
|
||||||
if 1 = FIRST.type and upcase(type)='IMLMODULE' then /* header, for IML modules */
|
if 1 = FIRST.type and upcase(type)='IMLMODULE' then /* header, for IML modules */
|
||||||
do;
|
do;
|
||||||
put "proc iml; ";
|
put "proc iml; ";
|
||||||
@@ -1731,7 +1785,7 @@ data _null_;
|
|||||||
/* include the file with the code of the element */
|
/* include the file with the code of the element */
|
||||||
put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /;
|
put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /;
|
||||||
|
|
||||||
/* FOOTERS for IML and FCMP */
|
/* FOOTERS for IML, FCMP, and PROTO */
|
||||||
if 1 = LAST.type and upcase(type)='FUNCTIONS' then /* footer, for multiple functions in one FCMP run */
|
if 1 = LAST.type and upcase(type)='FUNCTIONS' then /* footer, for multiple functions in one FCMP run */
|
||||||
do;
|
do;
|
||||||
put "run; ";
|
put "run; ";
|
||||||
@@ -1742,11 +1796,17 @@ data _null_;
|
|||||||
put "store module = _ALL_; "; /* and store all created modules */
|
put "store module = _ALL_; "; /* and store all created modules */
|
||||||
put "quit; ";
|
put "quit; ";
|
||||||
end;
|
end;
|
||||||
|
if 1 = LAST.type and upcase(type)='PROTO' then /* footer, for multiple functions in one PROTO run */
|
||||||
|
do;
|
||||||
|
put "run; ";
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
isFunction + (upcase(type)=:'FUNCTION');
|
isFunction + (upcase(type)=:'FUNCTION');
|
||||||
isFormat + (upcase(type)=:'FORMAT');
|
isFormat + (upcase(type)=:'FORMAT');
|
||||||
|
isProto + (upcase(type)=:'PROTO');
|
||||||
|
|
||||||
/* add the link to the functions' dataset, only for the first occurrence */
|
/* add the link to the functions dataset, only for the first occurrence */
|
||||||
if 1 = isFunction and (upcase(type)=:'FUNCTION') then
|
if 1 = isFunction and (upcase(type)=:'FUNCTION') then
|
||||||
do;
|
do;
|
||||||
put "options APPEND=(cmplib = work.%lowcase(&packageName.fcmp));";
|
put "options APPEND=(cmplib = work.%lowcase(&packageName.fcmp));";
|
||||||
@@ -1754,7 +1814,15 @@ data _null_;
|
|||||||
put '%put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
put '%put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
/* add the link to the formats' catalog, only for the first occurrence */
|
/* add the link to the proto functions dataset, only for the first occurrence */
|
||||||
|
if 1 = isProto and (upcase(type)=:'PROTO') then
|
||||||
|
do;
|
||||||
|
put "options APPEND=(cmplib = work.%lowcase(&packageName.proto));";
|
||||||
|
put '%put NOTE- ;';
|
||||||
|
put '%put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
||||||
|
end;
|
||||||
|
|
||||||
|
/* add the link to the formats catalog, only for the first occurrence */
|
||||||
if 1 = isFormat and (upcase(type)=:'FORMAT') then
|
if 1 = isFormat and (upcase(type)=:'FORMAT') then
|
||||||
do;
|
do;
|
||||||
put "options INSERT=( fmtsearch = work.%lowcase(&packageName.format) );";
|
put "options INSERT=( fmtsearch = work.%lowcase(&packageName.format) );";
|
||||||
@@ -1955,6 +2023,31 @@ data _null_;
|
|||||||
put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /;
|
put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
/* delete proto functions */
|
||||||
|
isProto = 0;
|
||||||
|
EOF = 0;
|
||||||
|
do until(EOF);
|
||||||
|
set &filesWithCodes. end = EOF;
|
||||||
|
if not (upcase(type)=:'PROTO') then continue;
|
||||||
|
put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;';
|
||||||
|
put '%put NOTE- ;' /;
|
||||||
|
isProto + 1;
|
||||||
|
end;
|
||||||
|
/* delete the link to the proto functions dataset */
|
||||||
|
if isProto then
|
||||||
|
do;
|
||||||
|
put "proc delete data = work.%lowcase(&packageName.proto);";
|
||||||
|
put "run;" /;
|
||||||
|
put 'options cmplib = (%unquote(%sysfunc(tranwrd(' /
|
||||||
|
'%lowcase(%sysfunc(getoption(cmplib)))' /
|
||||||
|
',%str(' "work.%lowcase(&packageName.proto)" '), %str() ))));';
|
||||||
|
put 'options cmplib = (%unquote(%sysfunc(compress(' /
|
||||||
|
'%sysfunc(getoption(cmplib))' /
|
||||||
|
',%str(()) ))));';
|
||||||
|
put '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
/* delete functions */
|
/* delete functions */
|
||||||
put "proc fcmp outlib = work.%lowcase(&packageName.fcmp).package;";
|
put "proc fcmp outlib = work.%lowcase(&packageName.fcmp).package;";
|
||||||
isFunction = 0;
|
isFunction = 0;
|
||||||
@@ -2101,7 +2194,7 @@ data _null_;
|
|||||||
put " infile &_PackageFileref_.(description.sas) end = EOF; ";
|
put " infile &_PackageFileref_.(description.sas) end = EOF; ";
|
||||||
put ' input; ';
|
put ' input; ';
|
||||||
put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; ';
|
put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; ';
|
||||||
put ' if printer then put "*> " _infile_; ';
|
put ' if printer then put @1 _infile_; ';
|
||||||
put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; ';
|
put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; ';
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else stop; ';
|
put ' else stop; ';
|
||||||
@@ -2139,7 +2232,7 @@ data _null_;
|
|||||||
put ' end ; ';
|
put ' end ; ';
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
put 'put "***"; put "* SAS package generated by generatePackage, version 20200811 *"; put "***";';
|
put 'put "***"; put "* SAS package generated by generatePackage, version 20201001 *"; put "***";';
|
||||||
|
|
||||||
put 'run; ' /;
|
put 'run; ' /;
|
||||||
|
|
||||||
@@ -2149,7 +2242,7 @@ data _null_;
|
|||||||
put ' do until (EOF); ';
|
put ' do until (EOF); ';
|
||||||
put " infile &_PackageFileref_.(license.sas) end = EOF; ";
|
put " infile &_PackageFileref_.(license.sas) end = EOF; ";
|
||||||
put ' input; ';
|
put ' input; ';
|
||||||
put ' put "*> " _infile_; ';
|
put ' put @1 _infile_; ';
|
||||||
put ' end; ';
|
put ' end; ';
|
||||||
put ' else stop; ';
|
put ' else stop; ';
|
||||||
put 'run; ' /;
|
put 'run; ' /;
|
||||||
@@ -2180,6 +2273,7 @@ data _null_;
|
|||||||
when (upcase(type) = "MACRO") fileshort2 = cats('''%',fileshort,'()''');
|
when (upcase(type) = "MACRO") fileshort2 = cats('''%',fileshort,'()''');
|
||||||
when (upcase(type) =:"FUNCTION") fileshort2 = cats("'",fileshort,"()'");
|
when (upcase(type) =:"FUNCTION") fileshort2 = cats("'",fileshort,"()'");
|
||||||
when (upcase(type) =:"IMLMODULE") fileshort2 = cats("'",fileshort,"()'");
|
when (upcase(type) =:"IMLMODULE") fileshort2 = cats("'",fileshort,"()'");
|
||||||
|
when (upcase(type) =:"PROTO") fileshort2 = cats("'",fileshort,"()'");
|
||||||
when (upcase(type) = "FORMAT") fileshort2 = cats("'$",fileshort,".'");
|
when (upcase(type) = "FORMAT") fileshort2 = cats("'$",fileshort,".'");
|
||||||
otherwise fileshort2 = fileshort;
|
otherwise fileshort2 = fileshort;
|
||||||
end;
|
end;
|
||||||
@@ -2211,11 +2305,11 @@ data _null_;
|
|||||||
put ' call execute(" input; ");';
|
put ' call execute(" input; ");';
|
||||||
put ' call execute(" if upcase(strip(_infile_)) ';
|
put ' call execute(" if upcase(strip(_infile_)) ';
|
||||||
put ' = ''/*** HELP END ***/'' then printer = 0; ");';
|
put ' = ''/*** HELP END ***/'' then printer = 0; ");';
|
||||||
put ' call execute(" if printer then put ""*> "" _infile_; ");';
|
put ' call execute(" if printer then put @1 _infile_; ");';
|
||||||
put ' call execute(" if upcase(strip(_infile_)) ';
|
put ' call execute(" if upcase(strip(_infile_)) ';
|
||||||
put ' = ''/*** HELP START ***/'' then printer = 1; ");';
|
put ' = ''/*** HELP START ***/'' then printer = 1; ");';
|
||||||
put ' call execute(" end; ");';
|
put ' call execute(" end; ");';
|
||||||
put ' call execute(" put ""*> "" / ""*> ""; ");';
|
put ' call execute(" put "" "" / "" ""; ");';
|
||||||
put ' call execute(" stop; ");';
|
put ' call execute(" stop; ");';
|
||||||
put ' call execute("run; ");';
|
put ' call execute("run; ");';
|
||||||
put ' if lowcase(type) =: "data" then ';
|
put ' if lowcase(type) =: "data" then ';
|
||||||
@@ -2263,7 +2357,7 @@ data _null_;
|
|||||||
call execute(' if upcase(strip(_infile_)) = "/*** HELP END ***/" then test + (-1); ');
|
call execute(' if upcase(strip(_infile_)) = "/*** HELP END ***/" then test + (-1); ');
|
||||||
call execute(' if (test not in (.,0,1)) or (EOF and test) then ');
|
call execute(' if (test not in (.,0,1)) or (EOF and test) then ');
|
||||||
call execute(' do; ');
|
call execute(' do; ');
|
||||||
call execute(' put "ERR" "OR: unmatching or nested HELP tags!" _N_=; ');
|
call execute(' put "ERR" "OR: unmatched or nested HELP tags!" _N_=; ');
|
||||||
call execute(' abort; ');
|
call execute(' abort; ');
|
||||||
call execute(' end; ');
|
call execute(' end; ');
|
||||||
call execute(' if (EOF and test=.) then put "WARN" "ING: no HELP tags in the file." ; ');
|
call execute(' if (EOF and test=.) then put "WARN" "ING: no HELP tags in the file." ; ');
|
||||||
@@ -2281,6 +2375,31 @@ filename &_DESCR_. clear;
|
|||||||
filename &_LIC_. clear;
|
filename &_LIC_. clear;
|
||||||
filename &zipReferrence. clear;
|
filename &zipReferrence. clear;
|
||||||
|
|
||||||
|
/* create hash SHA256 id */
|
||||||
|
%if %sysfunc(exist(sashelp.vfunc, VIEW)) %then
|
||||||
|
%do;
|
||||||
|
filename &zipReferrence. "&filesLocation./%lowcase(&packageName.).zip";
|
||||||
|
filename &zipReferrence. list;
|
||||||
|
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=;
|
||||||
|
run;
|
||||||
|
proc print data = the_SHA256_hash_id noobs label;
|
||||||
|
run;
|
||||||
|
');
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
filename &zipReferrence. clear;
|
||||||
|
%end;
|
||||||
|
/*+++++++++++++++++++++++*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* tests of package are executed by default */
|
/* tests of package are executed by default */
|
||||||
%if %bquote(&testPackage.) ne Y %then
|
%if %bquote(&testPackage.) ne Y %then
|
||||||
%do;
|
%do;
|
||||||
@@ -2363,6 +2482,16 @@ data _null_;
|
|||||||
put " path=&filesLocation.) " /;
|
put " path=&filesLocation.) " /;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
/*
|
||||||
|
setup for testing session:
|
||||||
|
-sysin - file with the test code
|
||||||
|
-print - location of the *.lst output file
|
||||||
|
-log - location of the log file
|
||||||
|
-config - location of the default config file, i.e. "&SASROOT./sasv9.cfg"
|
||||||
|
-work - location for work
|
||||||
|
-noterminal - for batch execution mode
|
||||||
|
-rsasuser - to avoid the "Unable to copy SASUSER registry to WORK registry." warning
|
||||||
|
*/
|
||||||
systask kill sas0 wait;
|
systask kill sas0 wait;
|
||||||
%local sasstat0 TEST_0 TESTRC_0;;
|
%local sasstat0 TEST_0 TESTRC_0;;
|
||||||
%let TEST_0 = loading;
|
%let TEST_0 = loading;
|
||||||
@@ -2373,7 +2502,8 @@ systask command
|
|||||||
-log ""&dirForTest./&TEST_0..log""
|
-log ""&dirForTest./&TEST_0..log""
|
||||||
-config ""&SASROOT./sasv9.cfg""
|
-config ""&SASROOT./sasv9.cfg""
|
||||||
-work ""&dirForTest./work""
|
-work ""&dirForTest./work""
|
||||||
-noterminal"
|
-noterminal
|
||||||
|
-rsasuser"
|
||||||
taskname=sas0
|
taskname=sas0
|
||||||
status=sasstat0
|
status=sasstat0
|
||||||
WAIT
|
WAIT
|
||||||
@@ -2383,7 +2513,6 @@ WAIT
|
|||||||
data _null_;
|
data _null_;
|
||||||
infile "./loading.log" dlm='0a0d'x end=EOF;
|
infile "./loading.log" dlm='0a0d'x end=EOF;
|
||||||
input;
|
input;
|
||||||
if _N_ > 10; /* due to "Unable to copy SASUSER registry to WORK registry." */
|
|
||||||
if _INFILE_ =: 'WARNING:' then
|
if _INFILE_ =: 'WARNING:' then
|
||||||
do;
|
do;
|
||||||
warning+1;
|
warning+1;
|
||||||
@@ -2455,7 +2584,8 @@ systask command
|
|||||||
-config ""&SASROOT./sasv9.cfg""
|
-config ""&SASROOT./sasv9.cfg""
|
||||||
-work ""&dirForTest./work""
|
-work ""&dirForTest./work""
|
||||||
-autoexec ""&dirForTest./autoexec.sas""
|
-autoexec ""&dirForTest./autoexec.sas""
|
||||||
-noterminal"
|
-noterminal
|
||||||
|
-rsasuser"
|
||||||
taskname=sas&t.
|
taskname=sas&t.
|
||||||
status=sasstat&t.
|
status=sasstat&t.
|
||||||
WAIT
|
WAIT
|
||||||
@@ -2465,7 +2595,6 @@ WAIT
|
|||||||
data _null_;
|
data _null_;
|
||||||
infile "./&&TEST_&t...log" dlm='0a0d'x end=EOF;
|
infile "./&&TEST_&t...log" dlm='0a0d'x end=EOF;
|
||||||
input;
|
input;
|
||||||
if _N_ > 10; /* due to "Unable to copy SASUSER registry to WORK registry." */
|
|
||||||
if _INFILE_ =: 'WARNING:' then
|
if _INFILE_ =: 'WARNING:' then
|
||||||
do;
|
do;
|
||||||
warning+1;
|
warning+1;
|
||||||
@@ -2521,6 +2650,7 @@ proc sql;
|
|||||||
drop table &filesWithCodes.;
|
drop table &filesWithCodes.;
|
||||||
quit;
|
quit;
|
||||||
|
|
||||||
|
%ENDofgeneratePackage:
|
||||||
%mend generatePackage;
|
%mend generatePackage;
|
||||||
|
|
||||||
|
|
||||||
@@ -2541,6 +2671,8 @@ TODO: (in Polish)
|
|||||||
|
|
||||||
- dodac typ "iml" [v] (as imlmodule)
|
- dodac typ "iml" [v] (as imlmodule)
|
||||||
|
|
||||||
|
- dodac typ "proto" [v]
|
||||||
|
|
||||||
- lista wymaganych komponentow potrzebnych do działania SASa (na bazie proc SETINIT) [v]
|
- lista wymaganych komponentow potrzebnych do działania SASa (na bazie proc SETINIT) [v]
|
||||||
|
|
||||||
- sparwdzanie domknietosci, parzystosci i wystepowania tagow HELP START - HELP END w plikach [v]
|
- sparwdzanie domknietosci, parzystosci i wystepowania tagow HELP START - HELP END w plikach [v]
|
||||||
@@ -2549,13 +2681,13 @@ TODO: (in Polish)
|
|||||||
|
|
||||||
- infolista o required packahes w unloadPackage [v]
|
- infolista o required packahes w unloadPackage [v]
|
||||||
|
|
||||||
- weryfikacja nadpisywania makr [ ]
|
|
||||||
|
|
||||||
- dodac ICEloadPackage() [v]
|
- dodac ICEloadPackage() [v]
|
||||||
|
|
||||||
|
- weryfikacja nadpisywania makr [ ]
|
||||||
|
|
||||||
- weryfikacja srodowiska [ ]
|
- weryfikacja srodowiska [ ]
|
||||||
|
|
||||||
- dodac typ "ds2", "proto" [ ]
|
- dodac typ "ds2" [ ]
|
||||||
|
|
||||||
- dodac mozliwosc szyfrowania pliku z pakietem (haslo do zip, sprawdzic istnienie funkcjonalnosci) [ ]
|
- dodac mozliwosc szyfrowania pliku z pakietem (haslo do zip, sprawdzic istnienie funkcjonalnosci) [ ]
|
||||||
|
|
||||||
@@ -2584,3 +2716,258 @@ TODO: (in Polish)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*** HELP END ***/
|
/*** HELP END ***/
|
||||||
|
|
||||||
|
/*** HELP START ***/
|
||||||
|
|
||||||
|
%macro loadPackageS(
|
||||||
|
packagesNames /* A comma separated list of packages name,
|
||||||
|
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 20201001. 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 20201001 #;
|
||||||
|
%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(%%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 # 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/master/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 ;
|
||||||
|
%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;
|
||||||
|
|
||||||
|
|
||||||
|
/*** 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 20201001. 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 20201001 #;
|
||||||
|
%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(%%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 # 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 # 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 # hash= A value of the package SHA256 hash. #;
|
||||||
|
%put # Provided by the user. #;
|
||||||
|
%put # #;
|
||||||
|
%put ###############################################################################;
|
||||||
|
%put # #;
|
||||||
|
%put # Visit: https://github.com/yabwon/SAS_PACKAGES/tree/master/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 ;
|
||||||
|
%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( %%verifPackage%(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 fullstimer_tmp stimer_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.);
|
||||||
|
|
||||||
|
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 SUCCESFUL.";
|
||||||
|
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;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ To get started with SAS Packages try this [**`Getting Started with SAS Packages`
|
|||||||
## Available packages:
|
## Available packages:
|
||||||
Currently the following packages are available:
|
Currently the following packages are available:
|
||||||
|
|
||||||
- **SQLinDS**\[2.1\], 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.
|
- **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.
|
||||||
```
|
```
|
||||||
data class;
|
data class;
|
||||||
set %SQL(
|
set %SQL(
|
||||||
@@ -16,6 +16,10 @@ data class;
|
|||||||
WH = weight + height;
|
WH = weight + height;
|
||||||
run;
|
run;
|
||||||
```
|
```
|
||||||
|
SHA256 digest for SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
|
||||||
|
|
||||||
|
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/sqlinds.md "Documentation for SQLinDS")
|
||||||
|
|
||||||
|
|
||||||
- **DFA** (Dynamic Function Arrays)\[0.2\], 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.
|
- **DFA** (Dynamic Function Arrays)\[0.2\], 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.
|
||||||
```
|
```
|
||||||
@@ -44,23 +48,33 @@ data _null_;
|
|||||||
end;
|
end;
|
||||||
run;
|
run;
|
||||||
```
|
```
|
||||||
|
SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA
|
||||||
|
|
||||||
- **macroArray**\[0.3\], implementation of an array concept in a macrolanguage, e.g.
|
|
||||||
|
- **macroArray**\[0.5\], implementation of an array concept in a macro language, e.g.
|
||||||
```
|
```
|
||||||
%array(ABC[17] (111:127), macarray=Y);
|
%array(ABC[17] (111:127), macarray=Y);
|
||||||
|
|
||||||
|
%macro test();
|
||||||
%do i = 1 %to 17;
|
%do i = 1 %to 17;
|
||||||
%put &i.) %ABC(&i.);
|
%put &i.) %ABC(&i.);
|
||||||
%end;
|
%end;
|
||||||
|
%mend;
|
||||||
|
%test()
|
||||||
|
|
||||||
%let %ABC(13,i) = 999; /* i = insert */
|
%let %ABC(13,i) = 99999; /* i = insert */
|
||||||
|
|
||||||
%do i = 1 %to 17;
|
%do_over(ABC, phrase=%nrstr(
|
||||||
%put &i.) %ABC(&i.);
|
%put &_i_.%) %ABC(&_i_.);
|
||||||
%end;
|
),
|
||||||
|
which = 1:H:2
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
|
||||||
|
|
||||||
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
|
||||||
|
|
||||||
|
- **BasePlus**\[0.62\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||||
```
|
```
|
||||||
call arrMissToRight(myArray);
|
call arrMissToRight(myArray);
|
||||||
call arrFillMiss(17, myArray);
|
call arrFillMiss(17, myArray);
|
||||||
@@ -74,6 +88,9 @@ format x bool.;
|
|||||||
|
|
||||||
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
||||||
```
|
```
|
||||||
|
SHA256 digest for BasePlus: 278621A6D8BBBB791DEA4C215D4261F2CB8F8B76B1397F7FA9B2E4219E77CB5A
|
||||||
|
|
||||||
|
|
||||||
- **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)
|
||||||
|
SHA256 digest for dynMacroArray: 066186B94B2976167C797C6A6E6217E361E8DEB10F2AB81906E0A325E5243084
|
||||||
|
|
||||||
|
|||||||
15
packages/SHA256_for_packages.txt
Normal file
15
packages/SHA256_for_packages.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/* 20200914 */
|
||||||
|
macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
|
||||||
|
SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
|
||||||
|
|
||||||
|
/* 20200914 */
|
||||||
|
SQLinDS: DD5E319EB5AA29C7054EC428072F987E77C29D36874DED1AE5C62E4B300845EB
|
||||||
|
macroArray: 69F6CF496F921D0E21F3524FC7FD130B4B8290C1E0B9BB3ABEA212B734EBE8A1
|
||||||
|
|
||||||
|
/* 20200911 */
|
||||||
|
sqlindsdemo: CCA3CB51587E30D1A4338EAF732EF03E0922918AAA21C3ECF85CABE93CD2FB15
|
||||||
|
macroArray: 5C9208ADD091E354794C24FA830F527D17CFC758C24CB77BF2154949059F7E6F
|
||||||
|
BasePlus: 278621A6D8BBBB791DEA4C215D4261F2CB8F8B76B1397F7FA9B2E4219E77CB5A
|
||||||
|
SQLinDS: 3EBC11A0890B6128DDB51643DC91F9DA1BDBF283535664540887FA7E7EA9744F
|
||||||
|
dynMacroArray: 066186B94B2976167C797C6A6E6217E361E8DEB10F2AB81906E0A325E5243084
|
||||||
|
DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA
|
||||||
Binary file not shown.
BIN
packages/dfa.zip
BIN
packages/dfa.zip
Binary file not shown.
Binary file not shown.
1168
packages/macroarray.md
Normal file
1168
packages/macroarray.md
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
175
packages/sqlinds.md
Normal file
175
packages/sqlinds.md
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
- [The SQLinDS package [ver. 2.2]](#sqlinds-package)
|
||||||
|
- [Content description](#content-description)
|
||||||
|
* [library `dsSQL`](#library-dssql)
|
||||||
|
* [`%dsSQL_inner()` macro](#dssql-inner-macro)
|
||||||
|
* [`%SQL()` macro](#dssql-inner-macro)
|
||||||
|
* [`dsSQL()` function](#dssql-function)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# The SQLinDS package [ver. 2.2] <a name="sqlinds-package"></a> ###############################################
|
||||||
|
|
||||||
|
The **SQLinDS** package is an implementation of
|
||||||
|
the *macro-function-sandwich* concept introduced in the
|
||||||
|
*"Use the Full Power of SAS in Your Function-Style Macros"*,
|
||||||
|
the article by *Mike Rhoads (Westat, Rockville)*.
|
||||||
|
|
||||||
|
Copy of the article is available at:
|
||||||
|
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
|
||||||
|
|
||||||
|
Package provides ability to *execute* SQL queries inside a data step, e.g.
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
data class;
|
||||||
|
set %SQL(select * from sashelp.class);
|
||||||
|
run;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
See the help for the `%SQL()` macro to find more examples.
|
||||||
|
|
||||||
|
### Content ###################################################################
|
||||||
|
|
||||||
|
SQLinDS package contains the following components:
|
||||||
|
|
||||||
|
1. `%SQL()` macro - the main package macro available for the User
|
||||||
|
2. `dsSQL()` function (internal)
|
||||||
|
3. `%dsSQL_inner()` macro (internal)
|
||||||
|
4. Library `DSSQL` (created as a subdirectory of the `WORK` library)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Package contains:
|
||||||
|
1. libname dssql
|
||||||
|
2. macro dssql_inner
|
||||||
|
3. macro sql
|
||||||
|
4. function dssql
|
||||||
|
|
||||||
|
Required SAS Components:
|
||||||
|
*Base SAS Software*
|
||||||
|
|
||||||
|
*SAS package generated by generatePackage, version 20200911*
|
||||||
|
|
||||||
|
The SHA256 hash digest for package SQLinDS:
|
||||||
|
`B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D`
|
||||||
|
|
||||||
|
---
|
||||||
|
# Content description ############################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
## >>> library `dsSQL`: <<< <a name="library-dssql"></a> ########################
|
||||||
|
|
||||||
|
The `dsSQL` library stores temporary views
|
||||||
|
generated during the `%SQL()` macro execution.
|
||||||
|
|
||||||
|
If possible a subdirectory of the `WORK` location is created, like:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp";
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
if not possible, then redirects to the `WORK` location, like:
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))";
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## >>> `%dsSQL_Inner()` macro: <<< <a name="dssql-inner-macro"></a> #############
|
||||||
|
|
||||||
|
**Internal** macro called by `dsSQL()` function.
|
||||||
|
The macro generates a uniquely named SQL view on the fly
|
||||||
|
which is then stored in the `dsSQL` library.
|
||||||
|
|
||||||
|
Recommended for *SAS 9.3* and higher.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## >>> `%SQL()` macro: <<< <a name="dssql-macro"></a> ###########################
|
||||||
|
|
||||||
|
The **main** macro which allows to use
|
||||||
|
SQL queries in the data step.
|
||||||
|
|
||||||
|
Recommended for *SAS 9.3* and higher.
|
||||||
|
|
||||||
|
Based on the article *"Use the Full Power of SAS in Your Function-Style Macros"*
|
||||||
|
by *Mike Rhoads* (Westat, Rockville), available at:
|
||||||
|
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
|
||||||
|
|
||||||
|
### SYNTAX: ###################################################################
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
%sql(<nonempty sql querry code>)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The sql query code is limited to *32000* bytes.
|
||||||
|
|
||||||
|
### EXAMPLES: #################################################################
|
||||||
|
|
||||||
|
**EXAMPLE 1**: simple SQL query
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
data class_subset;
|
||||||
|
set %SQL(select name, sex, height from sashelp.class where age > 12);
|
||||||
|
run;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**EXAMPLE 2**: query with dataset options
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
data renamed;
|
||||||
|
set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2));
|
||||||
|
run;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**EXAMPLE 3**: dictionaries in the data step
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
data dictionary;
|
||||||
|
set %SQL(select * from dictionary.macros);
|
||||||
|
run;
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## >>> `dsSQL()` function: <<< <a name="dssql-function"></a> ####################
|
||||||
|
|
||||||
|
**Internal** function called by the `%SQL()` macro.
|
||||||
|
The function pass a query code from the `%SQL()`
|
||||||
|
macro to the `%dsSQL_Inner()` internal macro.
|
||||||
|
|
||||||
|
Recommended for *SAS 9.3* and higher.
|
||||||
|
|
||||||
|
### SYNTAX: ###################################################################
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||||
|
dsSQL(unique_index_2, query)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Arguments description**:
|
||||||
|
|
||||||
|
1. `unique_index_2` - *Numeric*, internal variable, a unique index for views.
|
||||||
|
|
||||||
|
2. `query` - *Character*, internal variable, contains query text.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## License ####################################################################
|
||||||
|
|
||||||
|
Copyright (c) 2012 Mike Rhoads
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
---
|
||||||
Binary file not shown.
Reference in New Issue
Block a user