version 20191118

emergency ICEloadPackage macro to load package when loadPackage() is unavaliable for some reasons
This commit is contained in:
yabwon
2019-11-18 21:52:25 +01:00
parent 72f3ab75df
commit b571a3619e
10 changed files with 75 additions and 2569 deletions

BIN
dfa.zip

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
/*** HELP START ***/
/*** HELP START ***/
/**############################################################################**/
/* */
@@ -8,8 +8,8 @@
/* I tested it the best I could */
/* but it comes with absolutely no warranty whatsoever. */
/* If you cause any damage or something - it will be your own fault. */
/* You've been warned! You are using it on your own risk. */
/* However, if you decide to use it don't forget to mention author: */
/* You have been warned! You are using it on your own risk. */
/* However, if you decide to use it do not forget to mention author: */
/* Bartosz Jablonski (yabwon@gmail.com) */
/* */
/* Here is the official version: */
@@ -36,7 +36,7 @@
*/
/**#############################################################################**/
/* Macros to generate SAS packages */
/* Macros to generate SAS packages, version 20191118 */
/* A SAS package is a zip file containing a group
of SAS codes (macros, functions, datasteps generating
data, etc.) wrapped up together and %INCLUDEed by
@@ -448,6 +448,48 @@ data _null_;
stop;
run;
/* emergency ICEloadPackage macro to load package when loadPackage()
is unavaliable for some reasons, example of use:
1) point to a zip file,
2) include iceloadpackage.sas
3) point to package folder,
4) load package
*//*
filename packages zip 'C:/SAS_PACKAGES/sqlinds.zip';
%include packages(iceloadpackage.sas);
filename packages 'C:/SAS_PACKAGES/';
%ICEloadpackage(sqlinds)
*/
data _null_;
file &zipReferrence.(iceloadpackage.sas);
put " ";
put ' /* Temporary replacement of loadPackage() macro. */ ';
put ' %macro ICEloadPackage( ';
put ' packageName /* name of a package */ ';
put ' , path = %sysfunc(pathname(packages)) /* location of a package */ ';
put ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ ';
put ' )/secure; ';
put ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; ';
put ' %local _PackageFileref_; ';
put ' %let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.); ';
put ' filename &_PackageFileref_. &ZIP. ';
put ' "&path./%lowcase(&packageName.).&zip." %unquote(&options.) ';
put ' ; ';
put ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; ';
put ' filename &_PackageFileref_. clear; ';
put ' filename &_PackageFileref_. &ZIP. ';
put ' "&path./%lowcase(&packageName.).&zip." %unquote(&options.) ';
put ' ENCODING = ';
put ' %if %bquote(&packageEncoding.) NE %then &packageEncoding. ; ';
put ' %include &_PackageFileref_.(load.sas) / &source2.; ';
put ' filename &_PackageFileref_. clear; ';
put ' %mend ICEloadPackage; ';
put " ";
run;
/* loading package files */
data _null_;
if NOBS = 0 then stop;
@@ -1178,28 +1220,14 @@ filename &zipReferrence. clear;
/*
options mprint;
ods html;
%generatePackage(
testowyPackageName
,0.01
,author
,contact
,filesLocation=E:\SAS_WORK_5400\testyGeneratePackage
)
*/
/*
TODO:
TODO: (in Polish)
- modyfikacja helpa, sprawdzanie kodu danje funkcji/makra/typu [v]
- opcjonalne sortowanie nazw folderow(<numer>_<typ>) [v]
- wewnętrzna nazwaz zmiennej z nazwa pakietu (na potrzeby kompilacji) [v]
- weryfikacja srodaowiska
- weryfikacja srodaowiska [ ]
- weryfikacja "niepustosci" obowiazkowych argumentow [v]
@@ -1207,62 +1235,30 @@ TODO:
- doadc sprawdzanie liczby wywołan procedury fcmp, format i slowa '%macro(' w plikach z kodami [ ]
- syspackages - makrozmienna z lista zaladowanych pakietow [v] as SYSloadedPackages
- syspackages - makrozmienna z lista zaladowanych pakietow [v] (as SYSloadedPackages)
- dodac typ "iml", "ds2", "proto"
- dodac typ "iml", "ds2", "proto" [ ]
-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]
-weryfikacja nadpisywania makr [ ]
- weryfikacja nadpisywania makr [ ]
-add MD5(&packageName.) value hash instead "package" word in filenames [v]
- add MD5(&packageName.) value hash instead "package" word in filenames [v]
-infolista o required packahes w unloadPackage [ ]
- infolista o required packahes w unloadPackage [v]
- dodac ICEloadPackage() [ ]
*/
/*** HELP START ***/
/* Example 1: */
/*
%include "C:\SAS_PACKAGES\generatePackage.sas";
ods html;
%generatePackage(filesLocation=C:\SAS_PACKAGES\SQLinDS)
%include "C:/SAS_PACKAGES/generatePackage.sas";
ods html;
%generatePackage(filesLocation=C:/SAS_PACKAGES/SQLinDS)
*/
/*
*"C:\SAS_PACKAGES\testyGeneratoraPakietow";
libname packages "E:\SAS_WORK_5400\testyGeneratePackage";
filename packages "E:\SAS_WORK_5400\testyGeneratePackage";
%include packages(loadpackage.sas);
dm 'log;clear';
%loadpackage(testowypackagename)
*/
/*
%let helpKeyword=*;
%helpPackage(testowypackagename)
%unloadPackage(testowypackagename)
filename package ZIP "E:\SAS_WORK_5400\testyGeneratePackage\testowypackagename.zip";
%put %sysfunc(pathname(package));
%include package(load.sas);
%help()???
%include package(unload.sas);
filename package ZIP "C:\SAS_PACKAGES\testowypackagename.zip";
%include package(load.sas);
%include package(unload.sas);
filename package ZIP "C:\SAS_PACKAGES\macroarray.zip";
%include package(load.sas);
%include package(unload.sas);
*/
/*** HELP END ***/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@
/* I tested it the best I could */
/* but it comes with absolutely no warranty whatsoever. */
/* If you cause any damage or something - it will be your own fault. */
/* You've been warned! You are using it on your own risk. */
/* However, if you decide to use it don't forget to mention author: */
/* You have been warned! You are using it on your own risk. */
/* However, if you decide to use it do not forget to mention author: */
/* Bartosz Jablonski (yabwon@gmail.com) */
/* */
/* Here is the official version: */
@@ -36,17 +36,13 @@
*/
/**#############################################################################**/
/* Macros to load or to unload SAS packages */
/* A SAS package is a zip file containing a group
of SAS codes (macros, functions, datasteps generating
/* Macros to load, to get help, or to unload SAS packages, version 20191118 */
/* A SAS package is a zip file containing a group of files
with SAS code (macros, functions, datasteps generating
data, etc.) wrapped up together and %INCLUDEed by
a single load.sas file (also embedded inside the zip).
*/
/*
TODO:
- macro for testing available packages in the packages' folder [DONE] checkout: %listPackages()
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
*/
/*** HELP END ***/
/*** HELP START ***/
@@ -237,6 +233,11 @@ TODO:
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
%mend helpPackage;
/*
TODO:
- macro for testing available packages in the packages folder [DONE] checkout: %listPackages()
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
*/
/*** HELP START ***/

View File

@@ -1,228 +0,0 @@
/*** HELP START ***/
/**############################################################################**/
/* */
/* Copyright Bartosz Jablonski, July 2019. */
/* */
/* Code is free and open source. If you want - you can use it. */
/* I tested it the best I could */
/* but it comes with absolutely no warranty whatsoever. */
/* If you cause any damage or something - it will be your own fault. */
/* You've been warned! You are using it on your own risk. */
/* However, if you decide to use it don't forget to mention author: */
/* Bartosz Jablonski (yabwon@gmail.com) */
/* */
/* Here is the official version: */
/*
Copyright (c) 2019 Bartosz Jablonski (yabwon@gmail.com)
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.
*/
/**#############################################################################**/
/* Macros to load or to unload SAS packages */
/* A SAS package is a zip file containing a group
of SAS codes (macros, functions, datasteps generating
data, etc.) wrapped up together and %INCLUDEed by
a single load.sas file (also embedded inside the zip).
*/
/*
TODO:
- macro for testing available packages in the packages' folder [DONE] checkout: %listPackages()
*/
/*** HELP END ***/
/*** HELP START ***/
%macro loadPackage(
packageName /* name of a package,
e.g. myPackageFile.zip,
required and not null */
, path = %sysfunc(pathname(packages)) /* location of a package,
by default it looks for
location of "packages" fileref */
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
, source2 = /*source2*/ /* option to print out details,
null by default */
, requiredVersion = . /* option to test if loaded package
is provided in required version */
)/secure;
/*** HELP END ***/
%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));
%let source_tmp = %sysfunc(getoption(source));
options NOnotes NOsource ls=MAX ps=MAX;
filename package ZIP
/* put location of package myPackageFile.zip here */
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
;
%if %sysfunc(fexist(package)) %then
%do;
%include package(packagemetadata.sas) / &source2.;
filename package clear;
/* test if required version of package is "good enough" */
%if %sysevalf(&requiredVersion. > &packageVersion.) %then
%do;
%put ERROR: Required version is &requiredVersion.;
%put ERROR- Provided version is &packageVersion.;
%ABORT;
%end;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
filename package ZIP
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
ENCODING =
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
%else utf8 ;
;
%include package(load.sas) / &source2.;
%end;
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
filename package clear;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
%mend loadPackage;
/*** HELP START ***/
%macro unloadPackage(
packageName /* name of a package,
e.g. myPackageFile.zip,
required and not null */
, path = %sysfunc(pathname(packages)) /* location of a package,
by default it looks for
location of "packages" fileref */
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
, source2 = /*source2*/ /* option to print out details,
null by default */
)/secure;
/*** HELP END ***/
%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));
%let source_tmp = %sysfunc(getoption(source));
options NOnotes NOsource ls=MAX ps=MAX;
filename package ZIP
/* put location of package myPackageFile.zip here */
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
;
%if %sysfunc(fexist(package)) %then
%do;
%include package(packagemetadata.sas) / &source2.;
filename package clear;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
filename package ZIP
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
ENCODING =
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
%else utf8 ;
;
%include package(unload.sas) / &source2.;
%end;
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
filename package clear;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
%mend unloadPackage;
/*** HELP START ***/
%macro helpPackage(
packageName /* name of a package,
e.g. myPackageFile.zip,
required and not null */
, helpKeyword /* phrase to search in help,
when empty prints description
"*" means prints all help
"license" prints license */
, path = %sysfunc(pathname(packages)) /* location of a package,
by default it looks for
location of "packages" fileref */
, options = %str(LOWCASE_MEMNAME) /* possible options for ZIP filename */
, source2 = /*source2*/ /* option to print out details,
null by default */
)/secure;
/*** HELP END ***/
%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));
%let source_tmp = %sysfunc(getoption(source));
options NOnotes NOsource ls=MAX ps=MAX;
filename package ZIP
/* put location of package myPackageFile.zip here */
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
;
%if %sysfunc(fexist(package)) %then
%do;
%include package(packagemetadata.sas) / &source2.;
filename package clear;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
filename package ZIP
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
ENCODING =
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
%else utf8 ;
;
%include package(help.sas) / &source2.;
%end;
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
filename package clear;
options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
%mend helpPackage;
/*** HELP START ***/
/*
* Filenames references "packages" and "package" are keywords;
* the first one should be used to point folder with packages;
* the second is used internally by macros;
* Example 1:
* assuming that _THIS_FILE_ and the SQLinDS package (sqlinds.zip file)
* are located in the "C:/SAS_PACKAGES/" folder
* copy the following code into autoexec.sas
* or run it in your SAS session
**/
/*
filename packages "C:/SAS_PACKAGES";
%include packages(loadpackage.sas);
%loadpackage(SQLinDS)
%helpPackage(SQLinDS)
%unloadPackage(SQLinDS)
optional:
libname packages "C:/SAS_PACKAGES/";
%include "%sysfunc(pathname(packages))/loadpackage.sas";
%loadPackage(SQLinDS)
%helpPackage(SQLinDS)
%unloadPackage(SQLinDS)
*/
/*** HELP END ***/

Binary file not shown.

Binary file not shown.