mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-06 22:50:05 +00:00
loading required packages is now available
loading required packages is now available sience each package has its own unique file reference by MD5(packageName).
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
/*** HELP START ***/
|
||||
/*** HELP START ***/
|
||||
|
||||
/**############################################################################**/
|
||||
/* */
|
||||
@@ -52,7 +52,7 @@
|
||||
filesLocation=%sysfunc(pathname(work))/%lowcase(&packageName.)
|
||||
)/secure;
|
||||
/*** HELP END ***/
|
||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_;
|
||||
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _RC_ _PackageFileref_;
|
||||
%let zipReferrence = _%sysfunc(datetime(), hex6.)_;
|
||||
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
|
||||
%let _DESCR_ = _%sysfunc(datetime(), hex6.)d;
|
||||
@@ -153,6 +153,12 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 256;
|
||||
%abort;
|
||||
%end;
|
||||
|
||||
/* generate package fileref with MD5 to allow
|
||||
different file reference for each package
|
||||
while loading package with %loadPackage() macro
|
||||
*/
|
||||
%let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.);
|
||||
|
||||
/* test if version is a number */
|
||||
data _null_;
|
||||
version = input("&packageVersion.", ?? best32.);
|
||||
@@ -339,6 +345,7 @@ title2 "User: &SYSUSERID., datetime: %qsysfunc(datetime(), datetime21.), SAS ver
|
||||
title3 "Package's encoding: '&packageEncoding.', session's encoding: '&SYSENCODING.'.";
|
||||
title4 " ______________________________ ";
|
||||
title5 "List of files for package: &packageName. (version &packageVersion.), license: &packageLicense.";
|
||||
title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_.";
|
||||
proc print data = &filesWithCodes.(drop=base);
|
||||
run;
|
||||
title;
|
||||
@@ -429,7 +436,7 @@ data _null_;
|
||||
|
||||
file &zipReferrence.(load.sas) lrecl=32767;
|
||||
|
||||
put 'filename package list;' /;
|
||||
put "filename &_PackageFileref_. list;" /;
|
||||
put ' %put NOTE- ;';
|
||||
put ' %put NOTE: ' @; put "Loading package &packageName., version &packageVersion., license &packageLicense.; ";
|
||||
put ' %put NOTE: ' @; put "*** &packageTitle. ***; ";
|
||||
@@ -441,7 +448,7 @@ data _null_;
|
||||
put ' %put NOTE- ;';
|
||||
put ' %put NOTE- *** START ***; ' /;
|
||||
|
||||
put '%include package(packagemetadata.sas) / nosource2;' /; /* <- copied also to loadPackage macro */
|
||||
put '%include ' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /; /* <- copied also to loadPackage macro */
|
||||
isFunction = 0;
|
||||
isFormat = 0;
|
||||
|
||||
@@ -517,10 +524,44 @@ data _null_;
|
||||
|
||||
%if %bquote(&packageReqPackages.) ne %then
|
||||
%do;
|
||||
put ' data _null_ ; ';
|
||||
put ' length req name $ 64 SYSloadedPackages $ 32767; ';
|
||||
|
||||
length packageReqPackages $ 32767;
|
||||
packageReqPackages = lowcase(symget('packageReqPackages'));
|
||||
/* try to load required packages */
|
||||
put 'data _null_ ; ';
|
||||
put ' length req name $ 64 SYSloadedPackages $ 32767; ';
|
||||
put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ';
|
||||
put ' do; ';
|
||||
put ' do until(EOF); ';
|
||||
put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ';
|
||||
put ' substr(SYSloadedPackages, 1+offset, 200) = value; ';
|
||||
put ' end; ';
|
||||
put ' end; ';
|
||||
put ' SYSloadedPackages = lowcase(SYSloadedPackages); ';
|
||||
|
||||
put ' declare hash LP(); ';
|
||||
put ' LP.defineKey("name"); ';
|
||||
put ' LP.defineDone(); ';
|
||||
put ' do _N_ = 1 to countw(SYSloadedPackages); ';
|
||||
put ' name = scan(SYSloadedPackages, _N_); ';
|
||||
put ' _RC_ = LP.add(); ';
|
||||
put ' end; ';
|
||||
|
||||
put ' do req = ' / packageReqPackages / ' ; ';
|
||||
put ' name = lowcase(strip(scan(req, 1, " "))); ';
|
||||
put ' vers = lowcase(compress(scan(req,-1, " "), ".", "KD")); ';
|
||||
put ' if LP.check() ne 0 then ';
|
||||
put ' do; ';
|
||||
put ' put "NOTE: Trying to install required SAS package " req; ';
|
||||
put ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", vers, "))")); ';
|
||||
put ' end ; ';
|
||||
put ' end ; ';
|
||||
put ' stop; ';
|
||||
put 'run; ';
|
||||
|
||||
/* test if required packages are loaded */
|
||||
put 'data _null_ ; ';
|
||||
put ' length req name $ 64 SYSloadedPackages $ 32767; ';
|
||||
put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ';
|
||||
put ' do; ';
|
||||
put ' do until(EOF); ';
|
||||
@@ -544,8 +585,8 @@ data _null_;
|
||||
put ' if LP.check() ne 0 then ';
|
||||
put ' do; ';
|
||||
put ' missingPackagr = 1; ';
|
||||
put ' put "ERROR: SAS package " req "is missing! " ; ';
|
||||
put ' put ''ERROR- Try %loadPackage('' name ", requiredVersion = " vers ") to load it." ;';
|
||||
put ' put "ERROR: SAS package " req "is missing! Download it and" ; ';
|
||||
put ' put ''ERROR- use %loadPackage('' name ", requiredVersion = " vers ") to load it." ;';
|
||||
put ' end ; ';
|
||||
put ' end ; ';
|
||||
put ' if missingPackagr then call symputX("packageRequiredErrors", 1, "L"); ';
|
||||
@@ -557,8 +598,8 @@ data _null_;
|
||||
put ' do req = ' / packageReqPackages / ' ; ';
|
||||
put ' name = lowcase(strip(scan(req, 1, " "))); ';
|
||||
put ' vers = lowcase(compress(scan(req,-1, " "), ".", "KD")); ';
|
||||
put ' put "ERROR: SAS package " req "is missing! " ; ';
|
||||
put ' put ''ERROR- Try %loadPackage('' name ", requiredVersion = " vers ") to load it." ; ';
|
||||
put ' put "ERROR: SAS package " req "is missing! Download it and" ; ';
|
||||
put ' put ''ERROR- use %loadPackage('' name ", requiredVersion = " vers ") to load it." ; ';
|
||||
put ' end ; ';
|
||||
put ' end; ';
|
||||
put ' stop; ';
|
||||
@@ -592,7 +633,7 @@ data _null_;
|
||||
put '%put NOTE- Executing the following code: ;';
|
||||
put '%put NOTE- *****************************;';
|
||||
put 'data _null_;';
|
||||
put ' infile package(_' folder +(-1) "." file +(-1) ') lrecl=32767;';
|
||||
put " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;';
|
||||
put ' input;';
|
||||
put ' putlog "*> " _infile_;';
|
||||
put 'run;' /;
|
||||
@@ -600,7 +641,7 @@ data _null_;
|
||||
put '%put NOTE- ;';
|
||||
end;
|
||||
|
||||
put '%include package(_' folder +(-1) "." file +(-1) ') / nosource2;' /;
|
||||
put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /;
|
||||
|
||||
isFunction + (upcase(type)=:'FUNCTION');
|
||||
isFormat + (upcase(type)=:'FORMAT');
|
||||
@@ -663,7 +704,7 @@ data _null_;
|
||||
|
||||
file &zipReferrence.(unload.sas);
|
||||
|
||||
put 'filename package list;' /;
|
||||
put "filename &_PackageFileref_. list;" /;
|
||||
put '%put NOTE: '"Unloading package &packageName., version &packageVersion., license &packageLicense.;";
|
||||
put '%put NOTE- *** START ***;' /;
|
||||
|
||||
@@ -677,14 +718,14 @@ data _null_;
|
||||
put '%put NOTE- Executing the following code: ;';
|
||||
put '%put NOTE- *****************************;';
|
||||
put 'data _null_;';
|
||||
put ' infile package(_' folder +(-1) "." file +(-1) ') lrecl=32767;';
|
||||
put " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;';
|
||||
put ' input;';
|
||||
put ' putlog "*> " _infile_;';
|
||||
put 'run;' /;
|
||||
put '%put NOTE- *****************************;';
|
||||
put '%put NOTE- ;' /;
|
||||
|
||||
put '%include package(_' folder +(-1) "." file +(-1) ') / nosource2;' /;
|
||||
put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /;
|
||||
end;
|
||||
|
||||
/* delete macros and formats */
|
||||
@@ -847,7 +888,7 @@ data _null_;
|
||||
file &zipReferrence.(help.sas);
|
||||
length strX $ 32767;
|
||||
|
||||
put 'filename package list;' /;
|
||||
put "filename &_PackageFileref_. list;" /;
|
||||
put ' %put NOTE- ;';
|
||||
put ' %put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;";
|
||||
put ' %put NOTE: ' @; put "*** &packageTitle. ***; ";
|
||||
@@ -864,12 +905,12 @@ data _null_;
|
||||
put '%let notes_tmp = %sysfunc(getoption(notes)); ';
|
||||
put '%let source_tmp = %sysfunc(getoption(source)); ';
|
||||
put 'options ls = MAX ps = MAX nonotes nosource; ';
|
||||
put '%include package(packagemetadata.sas) / nosource2; ' /;
|
||||
put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /;
|
||||
|
||||
put 'data _null_; ';
|
||||
put ' if strip(symget("helpKeyword")) = " " then ';
|
||||
put ' do until (EOF); ';
|
||||
put ' infile package(description.sas) end = 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_; ';
|
||||
@@ -882,7 +923,7 @@ data _null_;
|
||||
put 'data _null_; ';
|
||||
put ' if upcase(strip(symget("helpKeyword"))) = "LICENSE" then ';
|
||||
put ' do until (EOF); ';
|
||||
put ' infile package(license.sas) end = EOF; ';
|
||||
put " infile &_PackageFileref_.(license.sas) end = EOF; ";
|
||||
put ' input; ';
|
||||
put ' put "*> " _infile_; ';
|
||||
put ' end; ';
|
||||
@@ -937,7 +978,7 @@ data _null_;
|
||||
put ' memberX = cats("_",folder,".",file); ';
|
||||
/* inner datastep in call execute to read each embedded file */
|
||||
put ' call execute("data _null_; ");';
|
||||
put ' call execute("infile package(" || strip(memberX) || ") end = EOF; ");';
|
||||
put " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');";
|
||||
put ' call execute(" printer = 0; ");';
|
||||
put ' call execute(" do until(EOF); ");';
|
||||
put ' call execute(" input; ");';
|
||||
|
||||
1096
generatePackage.sas_bckp
Normal file
1096
generatePackage.sas_bckp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/*** HELP START ***/
|
||||
/*** HELP START ***/
|
||||
|
||||
/**############################################################################**/
|
||||
/* */
|
||||
@@ -71,15 +71,17 @@ TODO:
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
options NOnotes NOsource ls=MAX ps=MAX;
|
||||
%local _PackageFileref_;
|
||||
%let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.);
|
||||
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(package)) %then
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include package(packagemetadata.sas) / &source2.;
|
||||
filename package clear;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
|
||||
/* test if required version of package is "good enough" */
|
||||
%if %sysevalf(&requiredVersion. > &packageVersion.) %then
|
||||
@@ -90,16 +92,16 @@ TODO:
|
||||
%end;
|
||||
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include package(load.sas) / &source2.;
|
||||
%include &_PackageFileref_.(load.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
|
||||
filename package clear;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
%mend loadPackage;
|
||||
|
||||
@@ -123,26 +125,28 @@ TODO:
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
options NOnotes NOsource ls=MAX ps=MAX;
|
||||
%local _PackageFileref_;
|
||||
%let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.);
|
||||
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(package)) %then
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include package(packagemetadata.sas) / &source2.;
|
||||
filename package clear;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include package(unload.sas) / &source2.;
|
||||
%include &_PackageFileref_.(unload.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
|
||||
filename package clear;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
%mend unloadPackage;
|
||||
|
||||
@@ -170,26 +174,28 @@ TODO:
|
||||
%let notes_tmp = %sysfunc(getoption(notes));
|
||||
%let source_tmp = %sysfunc(getoption(source));
|
||||
options NOnotes NOsource ls=MAX ps=MAX;
|
||||
%local _PackageFileref_;
|
||||
%let _PackageFileref_ = P%sysfunc(MD5(%lowcase(&packageName.)),hex7.);
|
||||
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
/* put location of package myPackageFile.zip here */
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
;
|
||||
%if %sysfunc(fexist(package)) %then
|
||||
%if %sysfunc(fexist(&_PackageFileref_.)) %then
|
||||
%do;
|
||||
%include package(packagemetadata.sas) / &source2.;
|
||||
filename package clear;
|
||||
%include &_PackageFileref_.(packagemetadata.sas) / &source2.;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
filename package ZIP
|
||||
filename &_PackageFileref_. ZIP
|
||||
"&path./%lowcase(&packageName.).zip" %unquote(&options.)
|
||||
ENCODING =
|
||||
%if %bquote(&packageEncoding.) NE %then &packageEncoding. ;
|
||||
%else utf8 ;
|
||||
;
|
||||
%include package(help.sas) / &source2.;
|
||||
%include &_PackageFileref_.(help.sas) / &source2.;
|
||||
%end;
|
||||
%else %put ERROR:[&sysmacroname] File "&path./&packageName..zip" does not exist;
|
||||
filename package clear;
|
||||
filename &_PackageFileref_. clear;
|
||||
options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
%mend helpPackage;
|
||||
|
||||
|
||||
228
loadpackage.sas_bckp
Normal file
228
loadpackage.sas_bckp
Normal file
@@ -0,0 +1,228 @@
|
||||
/*** 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. ¬es_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. ¬es_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. ¬es_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. ¬es_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. ¬es_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. ¬es_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 ***/
|
||||
BIN
macroarray.zip
BIN
macroarray.zip
Binary file not shown.
BIN
sqlinds.zip
BIN
sqlinds.zip
Binary file not shown.
Reference in New Issue
Block a user