mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-03 05:10:05 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f542d70332 | ||
|
|
80fdc9f214 | ||
|
|
f23afe7486 | ||
|
|
e467959d77 | ||
|
|
035e184b74 | ||
|
|
61d5806e79 | ||
|
|
98871647dd | ||
|
|
16b744a763 | ||
|
|
4765dc5c43 | ||
|
|
e1c95da0b7 | ||
|
|
319dd8c46b | ||
|
|
96555584a3 | ||
|
|
a6cfb9f93f | ||
|
|
63b30d7b6e | ||
|
|
eef8649f3c | ||
|
|
4511c812f0 | ||
|
|
5ca878d178 | ||
|
|
5c042cadff | ||
|
|
3eb09f29cd | ||
|
|
da3c8df259 | ||
|
|
b9fa8fc5d7 | ||
|
|
1fda328de8 | ||
|
|
322a951290 | ||
|
|
b090fdbe8d | ||
|
|
42663d56f7 | ||
|
|
bed882582e | ||
|
|
532f1ec90e | ||
|
|
861c5d866b | ||
|
|
f22d06fb42 | ||
|
|
c0212cb8af | ||
|
|
4ae8f23716 | ||
|
|
7fd4dd9774 | ||
|
|
f41d73cd90 | ||
|
|
863d6cb251 | ||
|
|
790816e229 | ||
|
|
88ace7321b | ||
|
|
f4ac0f1fe3 | ||
|
|
eb5cd6975c | ||
|
|
b975f75ff3 | ||
|
|
bb22a3e274 | ||
|
|
f981751c28 | ||
|
|
2f110adf1f | ||
|
|
5b1f8a3aae | ||
|
|
ef6473ad35 | ||
|
|
e30261410e | ||
|
|
3ede4541fd | ||
|
|
387898e01a |
20
README.md
20
README.md
@@ -6,13 +6,15 @@ 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 `20200730`.
|
||||
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`.
|
||||
|
||||
Read the **`SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf`** to learn more (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).
|
||||
|
||||
The documentation and more advance reading would be the [**`SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf`**](https://github.com/yabwon/SAS_PACKAGES/blob/master/SPF/Documentation/SAS(r)%20packages%20-%20the%20way%20to%20share%20(a%20how%20to)-%20Paper%204725-2020%20-%20extended.pdf "SAS packages - the way to share") article (see the `./SPF/Documentation` directory).
|
||||
|
||||
**General overview video:**
|
||||
- SAS Global Forum 2020 V.E.: `https://www.youtube.com/watch?v=qCkb-bx0Dv8&t=0s`
|
||||
- Sasensei Internationa Dojo: `https://www.youtube.com/watch?v=BFhdUBQgjYQ&t=0s`
|
||||
- [SAS Global Forum 2020 V.E.](https://www.youtube.com/watch?v=qCkb-bx0Dv8&t=0s "SGF2020")
|
||||
- [Sasensei Internationa Dojo](https://www.youtube.com/watch?v=BFhdUBQgjYQ&t=0s "SID no. 1")
|
||||
|
||||
### The User:
|
||||
To use a package:
|
||||
@@ -45,12 +47,12 @@ filename SPFinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/mast
|
||||
%loadPackage(packageName) /* load the package content into the SAS session */
|
||||
```
|
||||
|
||||
**Workshop video for the User**\[May 6th, 2020\]**: `https://youtu.be/qX_-HJ76g8Y`** [a bit outdated but gives the idea how it works]
|
||||
[**Workshop video for the User**](https://youtu.be/qX_-HJ76g8Y)\[May 6th, 2020\] [a bit outdated but gives the idea how it works]
|
||||
|
||||
### The Developer:
|
||||
To create your own package:
|
||||
- Read the **`SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf`** to learn more details.
|
||||
- Download and use the `SPFinit.sas` file (the SAS Packages Framework) file (user part of the framework required for *testing* is there too).
|
||||
- Read the [**`SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf`**](https://github.com/yabwon/SAS_PACKAGES/blob/master/SPF/Documentation/SAS(r)%20packages%20-%20the%20way%20to%20share%20(a%20how%20to)-%20Paper%204725-2020%20-%20extended.pdf "SAS packages - the way to share") to learn more details.
|
||||
- Download and use the `SPFinit.sas` file (the SAS Packages Framework), the part of the framework required for *testing* is there too.
|
||||
|
||||
#### If you have any questions, suggestions, or ideas do not hesitate to contact me!
|
||||
|
||||
@@ -86,7 +88,7 @@ run;
|
||||
%end;
|
||||
```
|
||||
|
||||
- **BasePlus**\[0.5\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||
```
|
||||
call arrMissToRight(myArray);
|
||||
call arrFillMiss(17, myArray);
|
||||
@@ -98,7 +100,7 @@ string = catXFn("date9.", "#", myArray);
|
||||
|
||||
format x bool.;
|
||||
|
||||
%put %getVars(sashelp.class, patern = ght$, sep = +, varRange = _numeric_);
|
||||
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
||||
```
|
||||
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
|
||||
|
||||
BIN
SPF/Documentation/Getting_Started_with_SAS_Packages.pdf
Normal file
BIN
SPF/Documentation/Getting_Started_with_SAS_Packages.pdf
Normal file
Binary file not shown.
Binary file not shown.
249
SPF/SPFinit.sas
249
SPF/SPFinit.sas
@@ -42,7 +42,7 @@
|
||||
- to unload, or
|
||||
- to generate SAS packages.
|
||||
|
||||
Version 20200730.
|
||||
Version 20200811.
|
||||
See examples below.
|
||||
|
||||
A SAS package is a zip file containing a group of files
|
||||
@@ -81,16 +81,22 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load SAS package, version 20200730. Run %loadPackage() for help info.'
|
||||
des = 'Macro to load SAS package, version 20200811. Run %loadPackage() for help info.'
|
||||
;
|
||||
%if %superq(packageName) = %then
|
||||
%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 20200730 #;
|
||||
%put # Macro to load SAS packages, version 20200811 #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -158,7 +164,8 @@ des = 'Macro to load SAS package, version 20200730. Run %loadPackage() for help
|
||||
%put ;
|
||||
%put ###############################################################################;
|
||||
%put ;
|
||||
%GOTO ENDloadPackage;
|
||||
options &options_tmp.;
|
||||
%RETURN;
|
||||
%end;
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
@@ -212,9 +219,6 @@ des = 'Macro to load SAS package, version 20200730. Run %loadPackage() for help
|
||||
¬es_tmp. &source_tmp.
|
||||
&stimer_tmp. &fullstimer_tmp.
|
||||
msglevel=&msglevel_tmp.;
|
||||
|
||||
/* jump here after running %loadPackage() - only help is displayed */
|
||||
%ENDloadPackage:
|
||||
%mend loadPackage;
|
||||
|
||||
/*** HELP START ***/
|
||||
@@ -238,16 +242,22 @@ des = 'Macro to load SAS package, version 20200730. Run %loadPackage() for help
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to unload SAS package, version 20200730. Run %unloadPackage() for help info.'
|
||||
des = 'Macro to unload SAS package, version 20200811. Run %unloadPackage() for help info.'
|
||||
;
|
||||
%if %superq(packageName) = %then
|
||||
%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 20200730 #;
|
||||
%put # Macro to unload SAS packages, version 20200811 #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -306,7 +316,8 @@ des = 'Macro to unload SAS package, version 20200730. Run %unloadPackage() for h
|
||||
%put ;
|
||||
%put ###############################################################################;
|
||||
%put ;
|
||||
%GOTO ENDunloadPackage;
|
||||
options &options_tmp.;
|
||||
%RETURN;
|
||||
%end;
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
@@ -338,8 +349,6 @@ des = 'Macro to unload SAS package, version 20200730. Run %unloadPackage() for h
|
||||
%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.;
|
||||
/* jump here after running %unloadPackage() - only help is displayed */
|
||||
%ENDunloadPackage:
|
||||
%mend unloadPackage;
|
||||
|
||||
/*** HELP START ***/
|
||||
@@ -367,16 +376,22 @@ des = 'Macro to unload SAS package, version 20200730. Run %unloadPackage() for h
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to get help about SAS package, version 20200730. Run %helpPackage() for help info.'
|
||||
des = 'Macro to get help about SAS package, version 20200811. Run %helpPackage() for help info.'
|
||||
;
|
||||
%if %superq(packageName) = %then
|
||||
%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 20200730 #;
|
||||
%put # Macro to get help about SAS packages, version 20200811 #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -440,7 +455,8 @@ des = 'Macro to get help about SAS package, version 20200730. Run %helpPackage()
|
||||
%put ;
|
||||
%put ###############################################################################;
|
||||
%put ;
|
||||
%GOTO ENDhelpPackage;
|
||||
options &options_tmp.;
|
||||
%RETURN;
|
||||
%end;
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
@@ -472,8 +488,6 @@ des = 'Macro to get help about SAS package, version 20200730. Run %helpPackage()
|
||||
%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.;
|
||||
/* jump here after running %helpPackage() - only help is displayed */
|
||||
%ENDhelpPackage:
|
||||
%mend helpPackage;
|
||||
|
||||
/*
|
||||
@@ -482,7 +496,7 @@ TODO:
|
||||
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
|
||||
*/
|
||||
|
||||
/* Macros to install SAS packages, version 20200730 */
|
||||
/* Macros to install SAS packages, version 20200811 */
|
||||
/* 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
|
||||
@@ -497,16 +511,22 @@ TODO:
|
||||
)
|
||||
/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to install SAS package, version 20200730. Run %%installPackage() for help info.'
|
||||
des = 'Macro to install SAS package, version 20200811. Run %%installPackage() for help info.'
|
||||
;
|
||||
%if %superq(packageName) = %then
|
||||
%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 installPackage macro #;
|
||||
%put ########################################################################################;
|
||||
%put # #;
|
||||
%put # Macro to install SAS packages, version 20200730 #;
|
||||
%put # Macro to install SAS packages, version 20200811 #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -558,7 +578,8 @@ des = 'Macro to install SAS package, version 20200730. Run %%installPackage() fo
|
||||
%put ;
|
||||
%put ########################################################################################;
|
||||
%put ;
|
||||
%GOTO ENDinstallPackage;
|
||||
options &options_tmp.;
|
||||
%RETURN;
|
||||
%end;
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp fullstimer_tmp stimer_tmp msglevel_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
@@ -652,8 +673,6 @@ des = 'Macro to install SAS package, version 20200730. Run %%installPackage() fo
|
||||
¬es_tmp. &source_tmp.
|
||||
&stimer_tmp. &fullstimer_tmp.
|
||||
msglevel=&msglevel_tmp.;
|
||||
/* jump here after running %installPackage() - only help is displayed */
|
||||
%ENDinstallPackage:
|
||||
%mend installPackage;
|
||||
|
||||
/*** HELP START ***/
|
||||
@@ -771,7 +790,7 @@ des = 'Macro to install SAS package, version 20200730. Run %%installPackage() fo
|
||||
|
||||
/* Macro to list SAS packages in packages folder.
|
||||
|
||||
Version 20200730
|
||||
Version 20200811
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -790,14 +809,66 @@ des = 'Macro to install SAS package, version 20200730. Run %%installPackage() fo
|
||||
/*** HELP END ***/
|
||||
|
||||
|
||||
%macro listPackages()/
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages() to run it, version 20200730.'
|
||||
%macro listPackages()/PARMBUFF
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20200811.'
|
||||
;
|
||||
%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 20200811 #;
|
||||
%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(%%listPackages()) macro lists packages available #;
|
||||
%put # in the packages folder. List is printed inthe SAS Log. #;
|
||||
%put # #;
|
||||
%put # Parameters: 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/master/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 ;
|
||||
%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.;
|
||||
%RETURN;
|
||||
%end;
|
||||
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp;
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp filesWithCodes;
|
||||
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
|
||||
|
||||
%local ls_tmp ps_tmp notes_tmp source_tmp;
|
||||
%let ls_tmp = %sysfunc(getoption(ls));
|
||||
%let ps_tmp = %sysfunc(getoption(ps));
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
@@ -848,7 +919,7 @@ data _null_;
|
||||
_INFILE_ = scan(_INFILE_,1,":") !! ":" !! scan(_INFILE_,2,":");
|
||||
putlog " * " _INFILE_;
|
||||
end;
|
||||
if strip(_INFILE_) = "DESCRIPTION START:" then leave;
|
||||
if upcase(strip(_INFILE_)) =: "DESCRIPTION START:" then leave;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -871,7 +942,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
/* Macro to generate SAS packages.
|
||||
|
||||
Version 20200730
|
||||
Version 20200811
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -886,7 +957,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
/*** HELP START ***/
|
||||
%macro generatePackage(
|
||||
filesLocation= /* location of package files
|
||||
filesLocation /* location of package files
|
||||
e.g. %sysfunc(pathname(work))/%lowcase(&packageName.) */
|
||||
,testPackage=Y /* indicator if tests should be executed,
|
||||
default value Y means "execute tests" */
|
||||
@@ -894,16 +965,22 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
dependencies in loading */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to generate SAS packages, version 20200730. Run %generatePackage() for help info.'
|
||||
des = 'Macro to generate SAS packages, version 20200811. Run %generatePackage() for help info.'
|
||||
;
|
||||
%if %superq(filesLocation) = %then
|
||||
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = 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 generatePackage macro #;
|
||||
%put ###############################################################################;
|
||||
%put # #;
|
||||
%put # Macro to generate SAS packages, version 20200730 #;
|
||||
%put # Macro to generate SAS packages, version 20200811 #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -934,7 +1011,8 @@ des = 'Macro to generate SAS packages, version 20200730. Run %generatePackage()
|
||||
%put # #;
|
||||
%put ###############################################################################;
|
||||
%put ;
|
||||
%GOTO ENDgeneratePackage;
|
||||
options &options_tmp.;
|
||||
%RETURN;
|
||||
%end;
|
||||
|
||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_ _PackageFileref_;
|
||||
@@ -978,7 +1056,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 256;
|
||||
when(upcase(scan(_INFILE_, 1, ":")) = "REQPACKAGES") call symputX("packageReqPackages", scan(_INFILE_, 2, ":"),"L");
|
||||
|
||||
/* stop at the beginning of description */
|
||||
when(upcase(scan(_INFILE_, 1, ":")) = "DESCRIPTION START") stop;
|
||||
when ( upcase(scan(_INFILE_, 1, ":")) = "DESCRIPTION START" ) stop;
|
||||
otherwise;
|
||||
end;
|
||||
run;
|
||||
@@ -1366,6 +1444,7 @@ data _null_;
|
||||
put ' , path = %sysfunc(pathname(packages)) /* location of a package */ ';
|
||||
put ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ ';
|
||||
put ' , zip = zip /* file ext. */ ';
|
||||
put ' , requiredVersion = . /* required version */ ';
|
||||
put ' , source2 = /* source2*/ ';
|
||||
put ' )/secure; ';
|
||||
put ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; ';
|
||||
@@ -1376,10 +1455,22 @@ data _null_;
|
||||
put ' ; ';
|
||||
put ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; ';
|
||||
put ' filename &_PackageFileref_. clear; ';
|
||||
|
||||
/* test if required version of package is "good enough" */
|
||||
put ' %if %sysevalf(&requiredVersion. > &packageVersion.) %then ';
|
||||
put ' %do; ';
|
||||
put ' %put ERROR: Required version is &requiredVersion.; ';
|
||||
put ' %put ERROR- Provided version is &packageVersion.; ';
|
||||
put ' %ABORT; ';
|
||||
put ' %end; ';
|
||||
|
||||
|
||||
put ' filename &_PackageFileref_. &ZIP. ';
|
||||
put ' "&path./%lowcase(&packageName.).&zip." %unquote(&options.) ';
|
||||
put ' ENCODING = ';
|
||||
put ' %if %bquote(&packageEncoding.) NE %then &packageEncoding. ;; ';
|
||||
put ' %if %bquote(&packageEncoding.) NE %then &packageEncoding. ; ';
|
||||
put ' %else utf8 ; ';
|
||||
put ' ; ';
|
||||
put ' %include &_PackageFileref_.(load.sas) / &source2.; ';
|
||||
put ' filename &_PackageFileref_. clear; ';
|
||||
put ' %mend ICEloadPackage; ';
|
||||
@@ -1506,18 +1597,24 @@ data _null_;
|
||||
put ' vers = input(compress(scan(req,-1, "("), ".", "KD"),best32.); ';
|
||||
put ' _RC_ = LP.add(); ';
|
||||
put ' end; ';
|
||||
/* check if elements of the framewor are available */
|
||||
put ' LoadPackageExist = input(resolve(''%SYSMACEXIST( loadPackage)''), best.); ';
|
||||
put ' ICELoadPackageExist = input(resolve(''%SYSMACEXIST(ICEloadPackage)''), best.); ';
|
||||
|
||||
put ' do req = ' / packageReqPackages / ' ; ';
|
||||
/* put ' req = compress(req, "(.)", "KDF"); ';*/
|
||||
put ' name = lowcase(strip(scan(req, 1, "("))); ';
|
||||
put ' verR = input(compress(scan(req,-1, "("), ".", "KD"),best32.); vers = .; ';
|
||||
put ' LP_find = LP.find(); ';
|
||||
put ' if (LP_find ne 0) or (LP_find = 0 and . < vers < verR) then ';
|
||||
put ' do; ';
|
||||
put ' put "NOTE: Trying to install required SAS package " req; ';
|
||||
put ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); ';
|
||||
put ' end ; ';
|
||||
put ' end ; ';
|
||||
put ' if (LP_find ne 0) or (LP_find = 0 and . < vers < verR) then ';
|
||||
put ' do; ';
|
||||
put ' put "NOTE: Trying to load required SAS package " req; ';
|
||||
put ' if LoadPackageExist then ';
|
||||
put ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); ';
|
||||
put ' else if ICELoadPackageExist then ';
|
||||
put ' call execute(cats(''%nrstr(%ICEloadPackage('', name, ", requiredVersion = ", verR, "))")); ';
|
||||
put ' end ; ';
|
||||
put ' end ; ';
|
||||
put ' stop; ';
|
||||
put 'run; ';
|
||||
|
||||
@@ -1733,14 +1830,18 @@ data _null_;
|
||||
put 'data _null_;';
|
||||
put ' length lazyData $ 32767; lazyData = lowcase(symget("lazyData"));';
|
||||
do until(eof);
|
||||
set &filesWithCodes.(where=( upcase(type) =: 'LAZYDATA' )) end = EOF nobs=NOBS;
|
||||
|
||||
put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then';
|
||||
put 'do;';
|
||||
put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";';
|
||||
put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');';
|
||||
put 'end;';
|
||||
set &filesWithCodes. end = EOF nobs=NOBS;
|
||||
|
||||
if ( upcase(type) =: 'LAZYDATA' ) then
|
||||
do;
|
||||
put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then';
|
||||
put 'do;';
|
||||
put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";';
|
||||
put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');';
|
||||
put 'end;';
|
||||
end;
|
||||
end;
|
||||
|
||||
put 'run;';
|
||||
|
||||
put '%put NOTE- ;';
|
||||
@@ -1994,16 +2095,16 @@ data _null_;
|
||||
put 'options ls = MAX ps = MAX nonotes nosource; ';
|
||||
put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /;
|
||||
|
||||
put 'data _null_; ';
|
||||
put ' if strip(symget("helpKeyword")) = " " then ';
|
||||
put ' do until (EOF); ';
|
||||
put " infile &_PackageFileref_.(description.sas) end = EOF; ";
|
||||
put ' input; ';
|
||||
put ' if upcase(strip(_infile_)) = "DESCRIPTION END:" then printer = 0; ';
|
||||
put ' if printer then put "*> " _infile_; ';
|
||||
put ' if upcase(strip(_infile_)) = "DESCRIPTION START:" then printer = 1; ';
|
||||
put ' end; ';
|
||||
put ' else stop; ';
|
||||
put 'data _null_; ';
|
||||
put ' if strip(symget("helpKeyword")) = " " then ';
|
||||
put ' do until (EOF); ';
|
||||
put " infile &_PackageFileref_.(description.sas) end = EOF; ";
|
||||
put ' input; ';
|
||||
put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; ';
|
||||
put ' if printer then put "*> " _infile_; ';
|
||||
put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; ';
|
||||
put ' end; ';
|
||||
put ' else stop; ';
|
||||
|
||||
|
||||
put ' put ; put " Package contains: "; ';
|
||||
@@ -2038,7 +2139,7 @@ data _null_;
|
||||
put ' end ; ';
|
||||
%end;
|
||||
|
||||
put 'put "***"; put "* SAS package generated by generatePackage, version 20200730 *"; put "***";';
|
||||
put 'put "***"; put "* SAS package generated by generatePackage, version 20200811 *"; put "***";';
|
||||
|
||||
put 'run; ' /;
|
||||
|
||||
@@ -2076,9 +2177,10 @@ data _null_;
|
||||
|
||||
select;
|
||||
when (upcase(type) in ("DATA" "LAZYDATA")) fileshort2 = fileshort;
|
||||
when (upcase(type) = "MACRO") fileshort2 = cats('%',fileshort,'()');
|
||||
when (upcase(type) =:"FUNCTION") fileshort2 = cats(fileshort,'()');
|
||||
when (upcase(type) = "FORMAT") fileshort2 = cats('$',fileshort);
|
||||
when (upcase(type) = "MACRO") fileshort2 = cats('''%',fileshort,'()''');
|
||||
when (upcase(type) =:"FUNCTION") fileshort2 = cats("'",fileshort,"()'");
|
||||
when (upcase(type) =:"IMLMODULE") fileshort2 = cats("'",fileshort,"()'");
|
||||
when (upcase(type) = "FORMAT") fileshort2 = cats("'$",fileshort,".'");
|
||||
otherwise fileshort2 = fileshort;
|
||||
end;
|
||||
strX = catx('/', folder, order, type, file, fileshort, fileshort2);
|
||||
@@ -2108,10 +2210,10 @@ data _null_;
|
||||
put ' call execute(" do until(EOF); ");';
|
||||
put ' call execute(" input; ");';
|
||||
put ' call execute(" if upcase(strip(_infile_)) ';
|
||||
put ' = cat(""/"",""*** "",""HELP END"","" ***"",""/"") then printer = 0; ");'; /* it looks like that because of comments */
|
||||
put ' = ''/*** HELP END ***/'' then printer = 0; ");';
|
||||
put ' call execute(" if printer then put ""*> "" _infile_; ");';
|
||||
put ' call execute(" if upcase(strip(_infile_)) ';
|
||||
put ' = cat(""/"",""*** "",""HELP START"","" ***"",""/"") then printer = 1; ");'; /* it looks like that because of comments */
|
||||
put ' = ''/*** HELP START ***/'' then printer = 1; ");';
|
||||
put ' call execute(" end; ");';
|
||||
put ' call execute(" put ""*> "" / ""*> ""; ");';
|
||||
put ' call execute(" stop; ");';
|
||||
@@ -2157,8 +2259,8 @@ data _null_;
|
||||
call execute(' retain test .;');
|
||||
call execute(' infile _SPFIN_ lrecl=32767 dlm="0a0d"x end=EOF;');
|
||||
call execute(' input;');
|
||||
call execute(' if upcase(strip(_infile_)) = cat("/","*** ","HELP START"," ***","/") then test + (+1); ');
|
||||
call execute(' if upcase(strip(_infile_)) = cat("/","*** ","HELP END", " ***","/") then test + (-1); ');
|
||||
call execute(' if upcase(strip(_infile_)) = "/*** HELP START ***/" 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(' do; ');
|
||||
call execute(' put "ERR" "OR: unmatching or nested HELP tags!" _N_=; ');
|
||||
@@ -2419,9 +2521,6 @@ proc sql;
|
||||
drop table &filesWithCodes.;
|
||||
quit;
|
||||
|
||||
|
||||
/* jump here after running %generatePackage() - only help is displayed */
|
||||
%ENDgeneratePackage:
|
||||
%mend generatePackage;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
## Available packages:
|
||||
## SAS Packages:
|
||||
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).
|
||||
|
||||
## Available packages:
|
||||
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.
|
||||
@@ -16,7 +19,7 @@ run;
|
||||
|
||||
- **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.
|
||||
```
|
||||
%createDFArray(ArrDynamic, resizefactor=17);
|
||||
%createDFArray(ArrDynamic, resizefactor=17);
|
||||
|
||||
data _null_;
|
||||
call ArrDynamic("Allocate", -2, 2);
|
||||
@@ -57,7 +60,7 @@ run;
|
||||
%end;
|
||||
```
|
||||
|
||||
- **BasePlus**\[0.5\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
|
||||
```
|
||||
call arrMissToRight(myArray);
|
||||
call arrFillMiss(17, myArray);
|
||||
@@ -69,7 +72,7 @@ string = catXFn("date9.", "#", myArray);
|
||||
|
||||
format x bool.;
|
||||
|
||||
%put %getVars(sashelp.class, patern = ght$, sep = +, varRange = _numeric_);
|
||||
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
|
||||
```
|
||||
|
||||
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
|
||||
|
||||
Binary file not shown.
BIN
packages/dfa.zip
BIN
packages/dfa.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user