Compare commits

...

4 Commits

Author SHA1 Message Date
Bart Jablonski
85510d353c SAS Packages Framework, version 20251231
SAS Packages Framework, version 20251231

Changes:
- New macro: %bundlePackages().
- New macro: %unbundlePackages().
- Bug fix in %verifyPackage() macro.
- Minor updates in %generatePackage(), %listPackages(), and %relocatePackage() macros.
- Documentation updated.
2025-12-31 15:29:26 +01:00
Bart Jablonski
cf74f74628 SAS Packages Framework, version 20251231
SAS Packages Framework, version 20251231

Changes:
- New macro: %bundlePackages().
- New macro: %unbundlePackages().
- Bug fix in %verifyPackage() macro.
- Minor updates in %generatePackage(), %listPackages(), and %relocatePackage() macros.
- Documentation updated.
2025-12-31 15:26:35 +01:00
Bart Jablonski
a41153746f SAS Packages Framework, version 20251221 and 20251228
SAS Packages Framework, version 20251221 and 20251228

This commit is to acknowledge contribution of:
- Stu Sztukowski in https://github.com/yabwon/SAS_PACKAGES/tree/20251221
- Ken Nakamatsu in https://github.com/yabwon/SAS_PACKAGES/tree/20251228

Co-Authored-By: Stu Sztukowski <64608711+stu-code@users.noreply.github.com>
Co-Authored-By: K.Nakamatsu <ken-nakamatsu@knworx.com>
2025-12-31 15:13:50 +01:00
Bart Jablonski
ec77a30477 SAS Packages Framework, version 20251228
SAS Packages Framework, version `20251228`:

Two new parameters were added to the `%generatePackage()`:
- `buildLocation=`,
- `archLocation=`.

The `easyArch=` option is independent.

Three technical sub-macros were extracted from the `%generatePackage()`.

Minor code housekeeping.

Documentation updated.

---

Code cleaning and new parameters are results of collaboration and discussion with Ken Nakamatsu (https://github.com/k-nkmt). Thanks Ken!
2025-12-29 09:01:13 +01:00
26 changed files with 5265 additions and 3002 deletions

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 - 2025 Bartosz Jablonski
Copyright (c) 2019 - 2026 Bartosz Jablonski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -4,7 +4,7 @@
---
A **SAS package** is an automatically generated, single, stand alone *zip* file containing organised and ordered code structures, created by the developer and extended with additional automatically generated "driving" files (i.e. description, metadata, load, unload, and help files).
A **SAS package** is an automatically generated, single, stand alone *zip* file containing organized and ordered code structures, created by the developer and extended with additional automatically generated "driving" files (i.e. description, metadata, load, unload, and help files).
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.
@@ -17,7 +17,7 @@ Don't forget to give the repository a **STAR** and become [stargazer](https://gi
### Current version:
**The latest version** of the **SAS Packages Framework** is **`20251221`**.
**The latest version** of the **SAS Packages Framework** is **`20251231`**.
---
@@ -190,13 +190,17 @@ The SAS Packages Framework [(short) documentation](https://github.com/yabwon/SAS
---
### Updates worth mentioning:
**Update**\[December 21st, 2025\]**:** `%relocatePackage()`, `%SasPackagesFrameworkNotes()`, and `%isPackagesFilerefOK()` **utility macros are available. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20241221 "splitCodeForPackage"))**.
**Update**\[December 31st, 2025\]**:** `%bundlePackages()` and `%unbundlePackages()` **macros are available. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20241231 "bundling macros"))**.
**Update**\[December 28th, 2025\]**:** `buildLocation=` and `archLocation=` **parameters added to** `%generatePackage()` **macro, they allow to redirect results of the packages generation process. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20251228 "redirect results with buildLocation="))**.
**Update**\[December 21st, 2025\]**:** `%relocatePackage()`, `%SasPackagesFrameworkNotes()`, and `%isPackagesFilerefOK()` **utility macros are available. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20241221 "relocatePackage, SasPackagesFrameworkNotes, and isPackagesFilerefOK macros"))**.
**Update**\[October 27th, 2024\]**:** `%splitCodeForPackage()` **utility macro is available. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20241027 "splitCodeForPackage"))**.
**Update**\[October 14th, 2024\]**:** `DS2PCK` and `DS2THR` **types for `PROC DS2` *threads* and *packages* added to the framework. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20241014 "PROC DS2"))**.
**Update**\[December 10th, 2023\]**:** `markdownDoc=` **parameter added to** `%generatePackage()` **macro, which allows to generate markdown file with documentation. Content is taken from the help information notes and the description. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20231210 "markdown documentation"))**.
**Update**\[December 10th, 2023\]**:** `markdownDoc=` **parameter added to** `%generatePackage()` **macro, it allows to generate markdown file with documentation. Content is taken from the help information notes and the description. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20231210 "markdown documentation"))**.
**Update**\[November 11th, 2023\]**:** `KMFSNIP` **type for *key macro abbreviations* snippets added to the framework. (see [here](https://github.com/yabwon/SAS_PACKAGES/releases/tag/20231111 "KMF-abbreviations"))**.
@@ -220,6 +224,8 @@ The SAS Packages Framework [(short) documentation](https://github.com/yabwon/SAS
**Update**\[June 3rd, 2020\]**:** `%installPackage()` **macro is available**. The `%installPackage()` macro is embedded in the `loadpackage.sas` part of the framework.
**Initial release**\[October 13th, 2019\]**: the SAS Packages Framework is publicly available**.
---
## Where the SAS Packages Framework is used:

View File

@@ -0,0 +1,502 @@
/*+bundlePackages+*/
%macro bundlePackages(
bundleName
,path=
,pathRef=
,packagesList=
,packagesPath=
,packagesRef=packages
,ods= /* data set for report file */
)/
des='Macro to create a bundle of SAS packages, version 20251231. Run %bundlePackages(HELP) for help info.'
secure minoperator
;
%if /*(%superq(bundleName) = ) OR*/ (%qupcase(&bundleName.) = 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 `bundlePackages` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *create bundles* of SAS packages, version `20251231` #;
%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(%%bundlePackages())` macro allows to bundle a bunch of SAS packages #;
%put # into a single file (a SAS packages bundle), just like a snapshot. #;
%put # #;
%put #-------------------------------------------------------------------------------#;
%put #### Parameters: #;
%put # #;
%put # 1. `bundleName` *Required.* Name of a bundle, e.g. myBundle, #;
%put # if the value is empty a default name is generated: #;
%put # `saspackagesbundle_createdYYYYMMDDtHHMMSS`, an #;
%put # extension `.bundle.zip` is automatically added. #;
%put # For value `HELP` this help information is displayed. #;
%put # #;
%put # - `path=` *Required.* Location of the bundle. Must be a valid #;
%put # directory. Takes precedence over `pathRef` parameter. #;
%put # Either `path=` or `pathRef=` must be non-empty. #;
%put # #;
%put # - `pathRef=` *Optional.* Fileref to location of the bundle. #;
%put # Either `path=` or `pathRef=` must be non-empty. #;
%put # #;
%put # - `packagesList=` *Optional.* A space-separated list of packages #;
%put # to bundle. If the value is empty all available #;
%put # packages are used. #;
%put # #;
%put # - `packagesPath=` *Optional.* Location of packages for the bundle. #;
%put # Takes precedence over `packagesRef` parameter. #;
%put # When non-empty, must be a valid directory. #;
%put # #;
%put # - `packagesRef=` *Optional.* Fileref to location of packages for the #;
%put # bundle. Default value is `packages`. #;
%put # #;
%put # - `ods=` *Optional.* Name of SAS data set for the report. #;
%put # #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
%put # to learn more. #;
%put # Tutorials available at: `https://github.com/yabwon/HoW-SASPackages` #;
%put # #;
%put ### Example 1 ###################################################################;
%put # #;
%put # Enabling the SAS Package Framework #;
%put # from the local directory and create a bundle of #;
%put # selected packages in user home directory. #;
%put # #;
%put # Assume that the `SPFinit.sas` file #;
%put # is located in the "/sas/PACKAGES/" folder. #;
%put # #;
%put # Run the following code in your SAS session: #;
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
%put %nrstr( filename packages "/sas/PACKAGES/"; %%* setup a directory for packages;);
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
%put ;
%put %nrstr( %%bundlePackages%(myLittleBundle );
%put %nrstr( ,path=/home/user/bundles );
%put %nrstr( ,packagesList=basePlus SQLinDS macroarray );
%put %nrstr( ,packagesRef=PACKAGES%) );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put # #;
%put #################################################################################;
%put ;
options &options_tmp.;
%GOTO ENDofbundlePackages;
%end;
/* local variables for options */
%local ls_tmp ps_tmp notes_tmp source_tmp stimer_tmp fullstimer_tmp msglevel_tmp mautocomploc_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));
%let mautocomploc_tmp = %sysfunc(getoption(mautocomploc));
options NOnotes NOsource ls=128 ps=MAX NOfullstimer NOstimer msglevel=N NOmautocomploc;
/*===================================================================================================*/
%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;
%local reportFile datetime;
%let datetime = %sysfunc(datetime());
%let reportFile = WORK.tmpbundlefile%sysfunc(int(&datetime.), b8601dt15.)_;
data _null_ %if %superq(ods) NE %then %do; &ods. %end;
%else %do; &reportFile.1 %end;
;
datetime=symgetn('datetime');
length packagesList $ 32767 bundleName $ 128;
packagesList = lowcase(compress(symget('packagesList'),"_ ","KAD")); /* keep only "proper" packages names */
bundleName = compress(symget('bundleName'),"_","KAD"); /* bundle name is letters, digits, and underscore, up to 128 symbols */
if bundleName NE symget('bundleName') then /* warn about illegal characters */
do;
put "WARNING: Bundle name has illegal characters, name will be modified.";
end;
if " "=bundleName then bundleName=cats("SASPackagesBundle_created", put(datetime,b8601dt.));
bundleName=lowcase(bundleName);
put / "INFO: Bundle name is: " bundleName / ;
length packagesPath $ 32767 packagesRef $ 8;
packagesPath = dequote(symget('packagesPath'));
packagesRef = upcase(strip(symget('packagesRef')));
/* organize source path (location of packages) */
if " "=packagesPath then
do;
if 0 then set SASHELP.VEXTFL(keep=level xpath xengine fileref exists);
DECLARE HASH sH(dataset:'SASHELP.VEXTFL(where=(fileref=' !! quote(packagesRef) !! '))', ordered: "A");
sH.DefineKey("level");
sH.DefineData("xpath","xengine","exists");
sH.DefineDone();
DECLARE HITER sI("sH");
if sH.NUM_ITEMS=0 then
do;
put "ERROR: Fileref in packagesRef= does NOT exist. Exiting!";
stop;
end;
packagesPath=" ";
if 1=sH.NUM_ITEMS then
do;
rc = sH.FIND(key:0);
if xengine = "DISK" AND exists='yes' then
packagesPath=quote(strip(xpath)); /* add quotes to the packagesPath */
else
put "WARNING: Path: " xpath "in packagesRef= is invalid! Path ignored!";
end;
else
do i = 1 to sum(sH.NUM_ITEMS,0);
rc = sH.FIND(key:i);
if exists='no'
then put "WARNING: Path: " xpath "in packagesRef= does NOT exist! Path ignored!";
else if xengine NE "DISK"
then put "WARNING: Engine in packagesRef= is not DISK! Path ignored!";
else packagesPath = catx(" ", packagesPath, quote(strip(xpath))); /* add quotes to the packagesPath */
end;
if " "=packagesPath then
do;
put "ERROR: Invalid directory in packagesRef=. Exiting!";
stop;
end;
if 1 < sH.NUM_ITEMS then packagesPath = cats("(", packagesPath, ')'); /* add brackets for multi-level path */
end;
else
do;
rcPckPath = fileexist(strip(packagesPath));
if 0=rcPckPath then
do;
put "ERROR: Path in packagesPath= does NOT exist. Exiting!";
stop;
end;
else packagesPath=quote(strip(packagesPath)); /* add quotes to the packagesPath */
end;
length path $ 32767 pathRef $ 8;
path = dequote(symget('path'));
pathRef = upcase(strip(symget('pathRef')));
if " "=path and " "=pathRef then
do;
put "ERROR: Path= and pathRef= are empty! Exiting!";
stop;
end;
/* verify target path (location of bundle) */
if " "=path then
do;
DECLARE HASH tH(dataset:'SASHELP.VEXTFL(where=(fileref=' !! quote(pathRef) !! '))', ordered: "A");
tH.DefineKey("level");
tH.DefineData("xpath","xengine","exists");
tH.DefineDone();
DECLARE HITER tI("tH");
if tH.NUM_ITEMS=0 then
do;
put "ERROR: Fileref in pathRef= does NOT exist. Exiting!";
stop;
end;
rc = tI.first();
if exists='no' then
do;
put "ERROR: Fileref in pathRef= does NOT exist. Exiting!";
stop;
end;
path = strip(xpath);
end;
else
do;
rcPath = fileexist(strip(path));
if 0=rcPath then
do;
put "ERROR: Path in Path= does NOT exist. Exiting!";
stop;
end;
end;
/* get the list of packages to bundle, don't worry if list is empty */
length pckNm pckVer pckDtm $ 24;
DECLARE HASH P(ordered:"A");
P.defineKey("pckNm");
P.defineDone();
DECLARE HASH Q(ordered:"A");
Q.defineKey("pckNm");
Q.defineData("pckNm",'pckVer','pckDtm');
Q.defineDone();
DECLARE HITER IQ("Q");
if " " NE packagesList then
do k=1 to countw(packagesList, " ");
pckNm = strip(scan(packagesList,k, " "));
rc = P.replace();
end;
packagesList = " ";
/* select all packages from source and intersect them with the list in packagesList ... */
put "INFO: List of packages available for bundle: ";
do k = 1 to kcountw(packagesPath, "()", "QS");
length base $ 1024;
base = dequote(kscanx(packagesPath, k, "()", "QS"));
length folder $ 64 file $ 1024 folderRef fileRef packageMetadata $ 8;
rc=filename(folderRef, base);
folderid=dopen(folderRef);
do i=1 to dnum(folderId);
folder = dread(folderId, i);
rc = filename(fileRef, catx("/", base, folder));
fileId = dopen(fileRef);
EOF = 0;
if fileId = 0 and lowcase(kscanx(folder, -1, ".")) = 'zip' then
do;
file = catx('/',base, folder);
rc1 = filename(packageMetadata, strip(file), 'zip', 'member="packagemetadata.sas"');
rcE = fexist(packageMetadata);
rc2 = filename(packageMetadata);
if rcE then /* if the packagemetadata.sas exists in the zip then check if package is on the list */
do;
pckNm = strip(scan(folder,1,"."));
if (0 = P.NUM_ITEMS) OR (0=P.find()) then
do;
pckVer='_._._';
pckDtm="____-__-__T__:__:__";
/*--------------------------------------------------*/
infile _DUMMY_ ZIP FILEVAR=file member="packagemetadata.sas" end=EOF;
do until(EOF);
input;
/*putlog ">>" _infile_;*/
select( lowcase(kscanx(_INFILE_,2,"(,)")) );
when ('"packageversion"' ) pckVer=dequote(strip(kscanx(_INFILE_,3,"(,)")));
when ('"packagegenerated"') pckDtm=dequote(strip(kscanx(_INFILE_,3,"(,)")));
otherwise;
end;
end;
/*--------------------------------------------------*/
pckVer=coalescec(pckVer,'_._._');
pckDtm=coalescec(pckDtm,"____-__-__T__:__:__");
if (pckVer='_._._' OR pckDtm="____-__-__T__:__:__") then
do;
put "WARNING: Incomplete metadata for package: " pckNm +(-1) "!";
rc = -1; /* ignore incomplete packages */
end;
else rc = Q.ADD();
if 0=rc then put base pckNm=;
end;
end;
end;
rc = dclose(fileId);
rc = filename(fileRef);
end;
rc = dclose(folderid);
rc = filename(folderRef);
end;
if 0=Q.NUM_ITEMS then /* ... if empty then exit */
do;
put "WARNING: No packages to bundle. Exiting!";
stop;
end;
else
do while(iQ.next()=0);
packagesList = catx(" ", packagesList, pckNm);
end;
if 0 < P.NUM_ITEMS NE Q.NUM_ITEMS then
do;
put "WARNING: Not all packages listed for bundling were found.";
end;
rc = Q.output(dataset:"&reportFile.3");
/* code executed for bundling */
length code1 code2 $ 32767;
code1=
'options ps=min nofullstimer nostimer msglevel=N; filename PACKAGES ' !! strip(packagesPath) !! ';' !!
'%relocatePackage(' !! strip(packagesList) !! ',target=' !! catx("/", path, bundleName) !!
'.bundle.zip, tDevice=ZIP,psMAX=MIN,ods=&reportFile.2(keep=package sFilename s_HASHING));';
code2=
'options noNotes;' !!
'filename _ ZIP ' !! quote(cats(path, "/", bundleName, ".bundle.zip")) !! ';' !!
'data _null_;set &reportFile.2;file _(verification.sas);' !!
'if 1=_N_ then put "/*" 64*"*" / "bundle created: ' !! put(datetime,e8601dt.) !! '" / 64*"*" "*/" /;' !!
'put ''%verifyPackage('' package +(-1) ",hash=F*" s_HASHING +(-1)")";run;' !!
'data &reportFile.4;merge &reportFile.2 &reportFile.3(rename=(pckNm=package));' !!
'by package;file _(bundlecontent.sas) dsd;hash="F*"!!s_HASHING; put package pckVer pckDtm hash;run;' !!
'title1 "Bundle: ' !! strip(bundleName) !! '";' !!
'title2 "Summary of bundling process";' !!
'proc print data=&reportFile.4 label;' !!
'var package pckVer pckDtm hash sFilename;' !!
'label package="Package name" pckVer="Version" pckDtm="Generation timestamp" sFilename="Source file location" hash="SHA256 for the Package";' !!
'proc delete data=&reportFile.2 &reportFile.3 &reportFile.4;run;title;';
/*put code=;*/
put "INFO: The " bundleName "bundle creation in progress...";
rc = doSubL(code1);
rc = doSubL(code2);
put "INFO: The " bundleName "bundle creation ended.";
%if &HASHING_FILE_exist. = 1 %then
%do;
rc = filename(fileRef, cats(path, "/", bundleName, ".bundle.zip"), "DISK", "lrecl=1 recfm=n");
rctxt=sysmsg();
if rc=0 then BundleSHA256 = "F*" !! HASHING_FILE("SHA256", pathname(fileRef,'F'), 0);
else put rctxt=;
put "INFO: SHA256 for the bundle is: " / @7 BundleSHA256;
rc = filename(fileRef);
%end;
keep path bundleName BundleSHA256 datetime;
label path = "Bundle location"
bundleName = "Bundle name"
BundleSHA256 = "SHA256 for the Bundle"
datetime = "Bundle generation timestamp"
;
format datetime e8601dt.;
output
%if %superq(ods) NE %then %do; %scan(&ods.,1,()) %end;
%else %do; &reportFile.1 %end;
;
put " ";
rc=sleep(1,1);
stop;
run;
title2 "Summary of the bundle file";;
proc print
data= %if %superq(ods) NE %then %do; %scan(&ods.,1,()) %end;
%else %do; &reportFile.1 %end;
noObs label;
var bundleName datetime BundleSHA256 path;
run;
%if %superq(ods) NE %then %do; %put INFO: Report file: %scan(&ods.,1,()); %end;
%else %do; proc delete data=&reportFile.1; run; %end;
/*===================================================================================================*/
/* restore optionos */
options ls = &ls_tmp. ps = &ps_tmp.
&notes_tmp. &source_tmp.
&stimer_tmp. &fullstimer_tmp.
msglevel=&msglevel_tmp. &mautocomploc_tmp.;
%ENDofbundlePackages:
%mend bundlePackages;
/*
filename packages ("C:\SAS_WORK\SAS_PACKAGES" "C:\SAS_PACKAGES_DEV" "R:\");
options mprint ls=64 ps=max;
%bundlePackages(
bundleNameTest123
,path=R:/
,ods=work.summaryofthebundlefile
)
%bundlePackages(
bundleNameTest124
,path=R:/
,packagesList=basePlus SQLinDS macroarray ABCDEF functionsimissinbase
,ods=work.summaryofthebundlefile1
)
data _null_;
set work.summaryofthebundlefile1;
call symputX("hashCheck",BundleSHA256);
run;
%verifyPackage(
bundlenametest124.bundle
,hash=&hashCheck.
)
%bundlePackages(
bundleNameTest125
,path=R:/dontexist
,packagesList=basePlus SQLinDS macroarray ABCDEF
)
options mprint ls=64 ps=max;
%bundlePackages(
bundleNameTest125
,pathRef=p
,packagesList=basePlus SQLinDS macroarray ABCDEF
)
bundleNameTest126
,path=R:\
,packagesList=basePlus SQLinDS macroarray ABCDEF
,packagesPath=R:/dontexist
,packagesRef=packages
)
filename p2 "R:/dontexist";
%bundlePackages(
bundleNameTest127
,path=R:\
,packagesList=basePlus SQLinDS macroarray ABCDEF
,packagesRef=p2
)
%bundlePackages(
bundleNameTest128
,path=R:\
,packagesList=basePlus SQLinDS macroarray ABCDEF
,packagesPath=R:/nopackages
)
%bundlePackages(
,path=R:/
,ods=work.summaryofthebundlefile
)
%bundlePackages(HELP)
%bundlePackages()
*/

View File

@@ -6,13 +6,13 @@
when empty the "packages" value is used */
)/secure
/*** HELP END ***/
des = 'Macro to list directories pointed by "packages" fileref, version 20251221. Run %extendPackagesFileref(HELP) for help info.'
des = 'Macro to list directories pointed by "packages" fileref, version 20251231. Run %extendPackagesFileref(HELP) for help info.'
;
%if %QUPCASE(&packages.) = HELP %then
%do;
%local options_tmp ;
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -22,7 +22,7 @@ des = 'Macro to list directories pointed by "packages" fileref, version 20251221
%put ### This is short help information for the `extendPackagesFileref` macro #;
%put #-----------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to list directories pointed by 'packages' fileref, version `20251221` #;
%put # Macro to list directories pointed by 'packages' fileref, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

File diff suppressed because it is too large Load Diff

View File

@@ -28,12 +28,12 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to get help about SAS package, version 20251221. Run %helpPackage() for help info.'
des = 'Macro to get help about SAS package, version 20251231. Run %helpPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%local options_tmp ;
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -43,7 +43,7 @@ des = 'Macro to get help about SAS package, version 20251221. Run %helpPackage()
%put ### This is short help information for the `helpPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to get help about SAS packages, version `20251221` #;
%put # Macro to get help about SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -1,5 +1,5 @@
/*+installPackage+*/
/* Macros to install SAS packages, version 20251221 */
/* Macros to install SAS packages, version 20251231 */
/* 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
@@ -26,12 +26,12 @@
/secure
minoperator
/*** HELP END ***/
des = 'Macro to install SAS package, version 20251221. Run %%installPackage() for help info.'
des = 'Macro to install SAS package, version 20251231. Run %%installPackage() for help info.'
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
%do;
%local options_tmp ;
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -41,7 +41,7 @@ des = 'Macro to install SAS package, version 20251221. Run %%installPackage() fo
%put ### This is short help information for the `installPackage` macro #;
%put #--------------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to install SAS packages, version `20251221` #;
%put # Macro to install SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -4,13 +4,13 @@
vERRb /* indicates if macro should be verbose and report errors */
)
/ minoperator PARMBUFF
des = 'Macro to check if the PACKAGES fileref is "correct", type %isPackagesFilerefOK(HELP) for help, version 20251221.'
des = 'Macro to check if the PACKAGES fileref is "correct", type %isPackagesFilerefOK(HELP) for help, version 20251231.'
;
/*** HELP END ***/
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -20,7 +20,7 @@ des = 'Macro to check if the PACKAGES fileref is "correct", type %isPackagesFile
%put ### This is short help information for the `isPackagesFilerefOK` macro #;
%put #-----------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to check if the `packages` fileref is "correct", version `20251221` #;
%put # Macro to check if the `packages` fileref is "correct", version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -3,7 +3,7 @@
Macro to list SAS packages in packages folder.
Version 20251221
Version 20251231
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -23,12 +23,12 @@
%macro listPackages()
/secure PARMBUFF
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20251221.'
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20251231.'
;
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -38,7 +38,7 @@ des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HE
%put ### This is short help information for the `listPackages` macro #;
%put #-----------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to list available SAS packages, version `20251221` #;
%put # Macro to list available SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -93,7 +93,7 @@ des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HE
options NOnotes NOsource ls=MAX ps=MAX;
data _null_;
length baseAll $ 32767;
length baseAll $ 32767 base $ 1024;
baseAll = pathname("packages");
if baseAll = " " then

View File

@@ -36,13 +36,13 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load SAS package, version 20251221. Run %loadPackage() for help info.'
des = 'Macro to load SAS package, version 20251231. Run %loadPackage() for help info.'
minoperator
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -52,7 +52,7 @@ minoperator
%put ### This is short help information for the `loadPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *load* SAS packages, version `20251221` #;
%put # Macro to *load* SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -19,13 +19,13 @@
is provided in required version */
)/secure
/*** HELP END ***/
des = 'Macro to load additional content for a SAS package, version 20251221. Run %loadPackageAddCnt() for help info.'
des = 'Macro to load additional content for a SAS package, version 20251231. Run %loadPackageAddCnt() for help info.'
minoperator
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -35,7 +35,7 @@ minoperator
%put ### This is short help information for the `loadPackageAddCnt` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *load* additional content for a SAS package, version `20251221` #;
%put # Macro to *load* additional content for a SAS package, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -11,13 +11,13 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load multiple SAS packages at one run, version 20251221. Run %loadPackages() for help info.'
des = 'Macro to load multiple SAS packages at one run, version 20251231. 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))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -27,7 +27,7 @@ parmbuff
%put ### This is short help information for the `loadPackageS` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro wrapper for the loadPackage macro, version `20251221` #;
%put # Macro wrapper for the loadPackage macro, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -23,12 +23,12 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to preview content of a SAS package, version 20251221. Run %previewPackage() for help info.'
des = 'Macro to preview content of a SAS package, version 20251231. Run %previewPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%local options_tmp ;
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -38,7 +38,7 @@ des = 'Macro to preview content of a SAS package, version 20251221. Run %preview
%put ### This is short help information for the `previewPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to get preview of a SAS packages, version `20251221` #;
%put # Macro to get preview of a SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -12,8 +12,10 @@
,try=3 /* integer between 1 and 9 */
,debug=0 /* debugging indicator */
,ignorePackagesFilerefCheck=0
,psMAX=MAX /* pageSise in case executed inside DoSubL() */
,ods= /* a data set for results, e.g., work.relocatePackageReport */
)
/ des = 'Utility macro that locally Copies or Moves Packages, version 20251221. Run %relocatePackage() for help info.'
/ des = 'Utility macro that locally Copies or Moves Packages, version 20251231. Run %relocatePackage() for help info.'
secure
minoperator
;
@@ -21,7 +23,7 @@
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -31,7 +33,7 @@
%put ### This is short help information for the `relocatePackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *locally copy or move* (relocate) SAS packages, version `20251221` #;
%put # Macro to *locally copy or move* (relocate) SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -156,7 +158,7 @@
%let msglevel_tmp = %sysfunc(getoption(msglevel));
%let mautocomploc_tmp = %sysfunc(getoption(mautocomploc));
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N NOmautocomploc;
options NOnotes NOsource ls=128 ps=&psMAX. NOfullstimer NOstimer msglevel=N NOmautocomploc;
%if NOT(%superq(debug) in (0 1)) %then %let debug=0;
%if NOT(%superq(move) in (0 1)) %then %let move=0;
@@ -183,8 +185,9 @@
%put WARNING: Checksum verification impossible! Minimum SAS version required for the process is 9.4M6. ;
%end;
data _null_;
putlog 32*"*" 24*"=" 32*"*";
data _null_ %if %superq(ods) NE %then %do; &ods. %end;
;
putlog 52*"*" 24*"=" 52*"*";
length packages source target $ 32767 sDevice tDevice $ 32;
packages = lowcase(compress(symget('packageName'),"_ ","KAD"));
@@ -334,7 +337,7 @@
do i = 1 to countw(packages, " ");
package = scan(packages, i, " ");
putlog 32*"*" package $24.-C 32*"*";
putlog 52*"*" package $24.-C 52*"*";
select;
/* copy from PACKAGES to some location */
@@ -562,6 +565,7 @@
/ "WARNING- Source is: " s_HASHING
/ "WARNING- Target is: " t_HASHING
/ "WARNING- There could be errors during copying. Check your files.";
%if %superq(ods) NE %then %do; output %scan(&ods.,1,()) ; %end;
end;
%end;
@@ -600,7 +604,7 @@
/* LINK 3 */
stopProcessing:
putlog 32*"*" 24*"=" 32*"*";
putlog 52*"*" 24*"=" 52*"*";
stop;
return;

View File

@@ -5,7 +5,7 @@ SPFmacroName /* space separated list of names */
/
minoperator
secure
des = 'Macro to provide help notes about SAS Packages Framework macros, version 20251221. Run %SasPackagesFrameworkNotes(HELP) for help info.'
des = 'Macro to provide help notes about SAS Packages Framework macros, version 20251231. Run %SasPackagesFrameworkNotes(HELP) for help info.'
;
%local list N i element;
%let list=
@@ -28,6 +28,8 @@ splitCodeForPackage
extendPackagesFileref
relocatePackage
isPackagesFilerefOK
bundlePackages
unbundlePackages
/**/
SasPackagesFrameworkNotes
;
@@ -38,7 +40,7 @@ SasPackagesFrameworkNotes
%if (%qupcase(&SPFmacroName.) = HELP) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
%sysfunc(getoption(mprint)) %sysfunc(getoption(mlogic)) %sysfunc(getoption(symbolgen))
@@ -49,14 +51,14 @@ SasPackagesFrameworkNotes
%put ### This is short help information for the `SasPackagesFrameworkNotes` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro prints help notes for SAS Packages Framework macros, version `20251221` #;
%put # Macro prints help notes for SAS Packages Framework macros, version `20251231` #;
%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(%%SasPackagesFrameworkNotes())` macro provides help notes about #;
%put # The `%nrstr(%%SasPackagesFrameworkNotes())` macro provides help notes about #;
%put # components of the SAS Packages Framework. #;
%put # #;
%put #-------------------------------------------------------------------------------#;
@@ -162,4 +164,3 @@ options mlogic symbolgen;
*/
/* end of SPFinit.sas file */

View File

@@ -0,0 +1,156 @@
/*+SPFint_gnPckg_arch+*/
%macro SPFint_gnPckg_arch()/secure minoperator
des='SAS Packages Framework internal macro. Executable only inside the %generatePackage() macro. The macro encapsulates the archive version generation part of the process. Version 20251231.';
/* macro picks up all macrovariables from external scope, so from the %generatePackage() macro */
%if %sysmexecname(%sysmexecdepth-1) in (GENERATEPACKAGE) %then
%do;
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
/*= generate files with version in the name START =========================================================================*/
/* to make archiving easier a copy of the package zip file
with the version in the name is created */
%if %superq(easyArch) NE 1 %then %let easyArch=0;
%if %superq(easyArch) = 1 %then
%do;
%put NOTE-;
%put NOTE: Creating files with version in the name.;
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
%put NOTE-;
%local notesSourceOptions;
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
options NOnotes NOsource;
%if %sysevalf(%superq(archLocation)=,boolean) %then
%do;
%let archLocation = &buildLocation.;
%end;
%else
%do;
%if 0=%sysfunc(FILEEXIST(%superq(archLocation))) %then
%do;
%put WARNING: The archLocation=%superq(archLocation) directory does NOT exist!;
%put WARNING- ;
%put WARNING- The %superq(buildLocation) directory will be used.;
%let archLocation = &buildLocation.;
%end;
%end;
%put NOTE: Arch location is: %superq(archLocation).;
%local archSufixList i archSfx;
/* by default list is only: "zip" */
%let archSufixList=zip;
/* if markdown is generated then "md" is added to the list */
%if &markdownDoc.=1 %then %let archSufixList = &archSufixList. md;
/* zip (md) */
%do i = 1 %to %sysfunc(countw(&archSufixList.));
%let archSfx=%scan(&archSufixList.,&i.);
filename &zipReferrence. "&buildLocation./%sysfunc(lowcase(&packageName.)).&archSfx." lrecl=1 recfm=n;
filename &zipReferrence. list;
filename &zipReferrenceV. "&archLocation./%sysfunc(lowcase(&packageName.))_&packageVersion._.&archSfx." lrecl=1 recfm=n;
filename &zipReferrenceV. list;
data _null_;
if NOT fexist("&zipReferrence.") then
do;
put "WARNING: No file to archive!";
stop;
end;
fexist = fexist("&zipReferrenceV.");
rc = fcopy("&zipReferrence.", "&zipReferrenceV.");
length rctxt $ 32767;
rctxt = sysmsg();
if rc then
do;
put "ERROR: An error " rc "occurred during creation of %sysfunc(lowcase(&packageName.))_&packageVersion._.&archSfx. file.";
put rctxt;
end;
else
do;
if fexist then put "Overwriting " @;
else put "Creating " @;
put "%sysfunc(lowcase(&packageName.))_&packageVersion._.&archSfx. file.";
end;
run;
filename &zipReferrence. clear;
filename &zipReferrenceV. clear;
%end;
options &notesSourceOptions.;
%end;
/*= generate files with version in the name END =========================================================================*/
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
%end;
%else
%do;
%put INFO: SAS Packages Framework internal macro. Executable only inside the %nrstr(%%)generatePackage() macro.;
%end;
%mend SPFint_gnPckg_arch;
/* END macros extracted outside generatePackage macro */
/*
TODO: (in Polish)
- modyfikacja helpa, sprawdzanie kodu danej funkcji/makra/typu [v]
- opcjonalne sortowanie nazw folderow(<numer>_<typ>) [v]
- wewnetrzna nazwa zmiennej z nazwa pakietu (na potrzeby kompilacji) [v]
- weryfikacja "niepustosci" obowiazkowych argumentow [v]
- dodac typ "clear" do czyszczenia po plikach 'exec' [v]
- syspackages - makrozmienna z lista zaladowanych pakietow [v] (as SYSloadedPackages)
- dodac typ "iml" [v] (as imlmodule)
- dodac typ "proto" [v]
- lista wymaganych komponentow potrzebnych do dzialania SASa (na bazie proc SETINIT) [v]
- sparwdzanie domknietosci, parzystosci i wystepowania tagow HELP START - HELP END w plikach [v]
- add MD5(&packageName.) value hash instead "package" word in filenames [v]
- infolista o required packahes w unloadPackage [v]
- dodac ICEloadPackage() [v]
- weryfikacja nadpisywania makr [v]
- weryfikacja srodowiska [ ]
- dodac typ "ds2" [v]
- dodac mozliwosc szyfrowania pliku z pakietem (haslo do zip, sprawdzic istnienie funkcjonalnosci) [ ]
- doadc sprawdzanie liczby wywolan procedury fcmp, format i slowa '%macro(' w plikach z kodami [ ]
- dodac generowanie funkcji z helpem np. dla funkcji abc() mamy abc_help(), ktora wyswietla to samo co %heplPackage(package, abc()) [ ]
*/
/*** HELP START ***/
/* Example 1: Enabling the SAS Package Framework
and generating the SQLinDS package from the local directory.
Assume that the SPFinit.sas file and the SQLinDS
folder (containing all package components) are located in
the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
ods html;
%generatePackage(filesLocation=C:/SAS_PACKAGES/SQLinDS)
*/
/*** HELP END ***/

View File

@@ -0,0 +1,253 @@
/*+SPFint_gnPckg_markdown+*/
%macro SPFint_gnPckg_markdown()/secure minoperator
des='SAS Packages Framework internal macro. Executable only inside the %generatePackage() macro. The macro encapsulates the markdown documentation part of the process. Version 20251231.';
/* macro picks up all macrovariables from external scope, so from the %generatePackage() macro */
%if %sysmexecname(%sysmexecdepth-1) in (GENERATEPACKAGE) %then
%do;
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
/* generate MarkDown documentation file */
/* check param value */
%if %superq(markdownDoc) NE 1 %then %let markdownDoc=0;
/* if true then execute */
%if &markdownDoc.=1 %then
%do;
%if %superq(createPackageContentStatus) NE 0 %then
%do;
%put ERROR- ** [&sysmacroname.] **;
%put ERROR: ** ERRORS IN PACKAGE CONTENT CREATION! **;
%put ERROR- ** NO MARKDOWN DOCUMMENTATION WILL BE GENERATED. **;
%GOTO NOmarkdownDoc;
%end;
/*= generate MarkDown documentation START =================================================================================*/
%put NOTE-;
%put NOTE: Preparing markdown documentation file.;
%put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
%put NOTE-;
%local MarkDownOptionsTmp;
%let MarkDownOptionsTmp =
%sysfunc(getoption(notes)) %sysfunc(getoption(source)) msglevel=%sysfunc(getoption(msglevel));
options NOnotes NOsource msglevel=N;
filename &zipReferrence. "&buildLocation./%sysfunc(lowcase(&packageName.)).md";
filename &_PackageFileref_. ZIP "&buildLocation./%sysfunc(lowcase(&packageName.)).zip";
data &filesWithCodes.markdown;
/* break if no data */
if NOBS = 0 then stop;
file &zipReferrence. encoding = &packageEncoding.;
put "# Documentation for the `&packageName.` package.";
length packageLicense packageGenerated $ 64
packageTitle packageAuthor packageMaintainer $ 4096
packageHashF packageHashC $ 128
;
packageLicense=symget("packageLicense");
packageTitle=symget("packageTitle");
packageGenerated=symget("packageGenerated");
packageAuthor=symget("packageAuthor");
packageMaintainer=symget("packageMaintainer");
packageHashF=symget("packageHashF");
packageHashC=symget("packageHashC");
drop package:;
put " " / 64*"-" / " "
/ ' *' packageTitle +(-1)'* '
/ " " / 64*"-" / " "
/ "### Version information:"
/ " "
/ "- Package: &packageName."
/ "- Version: &packageVersion."
/ "- Generated: " packageGenerated
/ "- Author(s): " packageAuthor
/ "- Maintainer(s): " packageMaintainer
/ "- License: " packageLicense
/ "- File SHA256: `" packageHashF +(-1) "` for this version"
/ "- Content SHA256: `" packageHashC +(-1) "` for this version"
/ " " / "---" / " ";
put "# The `&packageName.` package, version: `&packageVersion.`;"
/ " " / "---" / " ";
do until (EOF);
infile &_PackageFileref_.(description.sas) end = EOF;
input;
if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0;
if printer then put _infile_;
if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1;
end;
put " " / "---" / " ";
%if %superq(packageRequired) ne %then
%do;
put " " / "---" / " ";
length req $ 256;
put "Required SAS Components: ";
do req = &packageRequired. ;
put @3 "-" @5 req;
end ;
%end;
%if %superq(packageReqPackages) ne %then
%do;
put " " / "---" / " ";
length req2 $ 256;
put "Required SAS Packages: ";
do req2 = &packageReqPackages.;
put @3 "-" @5 req2;
end ;
%end;
put " " / "---" / " ";
%if %superq(additionalContent) NE %then
%do;
put " " / "---" / " ";
put 'Package contains additional content, run: `%loadPackageAddCnt(' "&packageName." ')` to load it'
/ "or look for the `%sysfunc(lowcase(&packageName.))_AdditionalContent` directory in the `packages` fileref"
/ "localization (only if additional content was deployed during the installation process).";
%end;
put " " / "---------------------------------------------------------------------" / " "
/ "*SAS package generated by SAS Package Framework, version `20251231`,*"
/ "*under `&sysscp.`(`&sysscpl.`) operating system,*"
/ "*using SAS release: `&sysvlong4.`.*"
/ " " / "---------------------------------------------------------------------" / " ";
put "# The `&packageName.` package content";
put "The `&packageName.` package consists of the following content:" / " ";
EOFDS = 0;
do until(EOFDS);
/* content is created during package creation */
set &filesWithCodes. end = EOFDS nobs = NOBS curobs = CUROBS;
if upcase(type) in: ('TEST') then continue; /* exclude tests */
/*
To exclude file from being added to the documentation
insert the "excluding" text(see below) as a comment
in the FIRST or SECOND line of the file!
Do not add spaces.
For each file the first line is read in and checked.
*/
length _FILEVARPATH_ $ 4096;
_FILEVARPATH_=catx("/",base,folder,file);
infile _dummy_ FILEVAR=_FILEVARPATH_;
input;
if strip(_infile_) IN (
'/*##DoNotUse4Documentation##*/'
'/*##ExcludeFromDocumentation##*/'
'/*##ExcludeFromMarkdownDoc##*/'
)
then continue; /* exclude file from documentation after FIRST line */
input;
if strip(_infile_) IN (
'/*##DoNotUse4Documentation##*/'
'/*##ExcludeFromDocumentation##*/'
'/*##ExcludeFromMarkdownDoc##*/'
)
then continue; /* exclude file from documentation after SECOND line */
/* this is because %splitCodeForPackage() macro adds one extra line */
type2=type;
length link $ 256;
link=catx("-",compress(fileshort,,"KAD"),type,CUROBS);
length fileshort $ 256;
select;
when (upcase(type) =: "MACRO" ) do; fileshort2 = cats('`%', fileshort, "()`"); type2='macro'; end;
when (upcase(type) =: "FORMAT" ) do; fileshort2 = cats("`$", fileshort, ".`"); type2='format/informat'; end;
when (upcase(type) =: "FUNCTION" ) do; fileshort2 = cats("`", fileshort, "()`"); type2='function'; end;
when (upcase(type) =: "IMLMODULE") fileshort2 = cats("`", fileshort, "()`");
when (upcase(type) =: "PROTO" ) fileshort2 = cats("`", fileshort, "()`");
when (upcase(type) =: "CASLUDF" ) fileshort2 = cats("`", fileshort, "()`");
otherwise fileshort2 = cats("`", fileshort, "`");
end;
contentObs + 1;
put @1 contentObs +(-1) '. [' fileshort2 type2'](#' link ')';
output;
end;
put " " / " ";
contentObs+1;
put @1 contentObs +(-1) '. [License note](#license)';
put " " / "---" / " ";
putlog "Doc. note with general information ready.";
stop;
run;
/* loop through content and print info to the MD file */
data _null_;
if 0 = NOBS then stop;
do until(EOFDS);
set &filesWithCodes.markdown end = EOFDS nobs = NOBS curobs=CUROBS;
length memberX $ 1024;
memberX = cats("_",folder,".",file);
/* inner data step in call execute to read each embedded file */
call execute("data _null_; ");
call execute(" file &zipReferrence. encoding = &packageEncoding. MOD; ");
call execute(' put ''## ' !! catx(" ",fileshort2,type2) !! ' <a name="' !! strip(link) !! '"></a> ######'';');
call execute(' infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');
call execute(" printer = 0; ");
call execute(" do until(EOF); ");
call execute(" input; length _endhelpline_ _starthelpline_ $ 32767; ");
call execute(" _endhelpline_ = upcase(reverse(strip(_infile_))); ");
call execute(" if 18 <= lengthn(_endhelpline_) AND _endhelpline_
=: '/*** DNE PLEH ***/' then printer = 0; "); /* ends with HELP END */
call execute(" if printer then put _infile_; ");
call execute(" _starthelpline_ = upcase(strip(_infile_)); ");
call execute(" if 20 <= lengthn(_starthelpline_) AND _starthelpline_
=: '/*** HELP START ***/' then printer = 1 ; "); /* starts with HELP START */
call execute(" end; ");
call execute(' put " " / "---" / " "; ');
call execute(' putlog ''Doc. note ' !! cats(CUROBS) !! ' for ' !! catx(" ",fileshort2,type2) !! ' ready.'';');
call execute(" stop; ");
call execute("run; ");
end;
stop;
run;
/* license info */
data _null_;
file &zipReferrence. encoding = &packageEncoding. MOD;
putlog "Doc. note with license ready.";
put " " / "---" / " "
/ '# License <a name="license"></a> ######' / " "
;
do until (EOF_L);
infile &_PackageFileref_.(license.sas) end = EOF_L;
input;
put _infile_;
end;
put " " / "---" / " ";
stop;
run;
options &MarkDownOptionsTmp.;
%put NOTE: Markdown file generated.;
filename &zipReferrence. list;
%put NOTE- ;
options NOnotes NOsource msglevel=N;
filename &zipReferrence. clear;
filename &_PackageFileref_. clear;
options &MarkDownOptionsTmp.;
/*= generate MarkDown documentation END =================================================================================*/
%NOmarkdownDoc:
%end;
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
%end;
%else
%do;
%put INFO: SAS Packages Framework internal macro. Executable only inside the %nrstr(%%)generatePackage() macro.;
%end;
%mend SPFint_gnPckg_markdown;

View File

@@ -0,0 +1,649 @@
/*+SPFint_gnPckg_tests+*/
%macro SPFint_gnPckg_tests()/secure minoperator
des='SAS Packages Framework internal macro. Executable only inside the %generatePackage() macro. The macro encapsulates the test part of the process. Version 20251231.';
/* macro picks up all macrovariables from external scope, so from the %generatePackage() macro */
%if %sysmexecname(%sysmexecdepth-1) in (GENERATEPACKAGE) %then
%do;
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
/* verify if there were errors while package content creation */
%if %superq(createPackageContentStatus) ne 0 %then
%do;
%put ERROR- ** [&sysmacroname.] **;
%put ERROR: ** ERRORS IN PACKAGE CONTENT CREATION! **;
%put ERROR- ** NO TESTING WILL BE EXECUTED. **;
%GOTO NOTESTING;
%end;
/* tests of package are executed by default */
%if NOT (%superq(testPackage) in (Y y 1)) %then
%do;
%put WARNING: ** NO TESTING WILL BE EXECUTED. **;
%GOTO NOTESTING;
%end;
%put NOTE-;
%put NOTE: Running tests.;
%put NOTE- ^^^^^^^^^^^^^^;
%put NOTE-;
/* in case the packages macrovariable is multi-directory the first directory will be selected */
data _null_;
length packages $ 32767;
packages = resolve(symget("packages"));
/* check if path contains quotes */
quotes = lengthn(compress(packages,"""'","K"));
/* issue error for unmatched quotes */
if mod(quotes,2) then
put "ERROR: Unbalanced quotes in the PACKAGES= parameter." / "ERROR- " PACKAGES= ;
if quotes > 0 then
call symputX("packages", dequote(kscanx(packages, 1, "()", "QS")) ,"L");
else
call symputX("packages", packages ,"L");
run;
/* check if systask is available */
%if %sysfunc(GETOPTION(XCMD)) = NOXCMD %then
%do;
data _null_;
put 'WARNING: NO TESTING WILL BE EXECUTED DUE TO NOXCMD.';
put '***************************************************';
put ;
put 'NOTE-To execute the loading test manualy';
put 'NOTE-run the following code:';
put 'NOTE-';
n=6;
length packages $ 32767;
packages = quote(dequote(strip(symget('packages'))));
put @n "filename packages " packages ";" /;
if fileexist("&packages./SPFinit.sas") then
put @n '%include packages(SPFinit.sas);' /;
else if fileexist("&packages./loadpackage.sas") then
put @n '%include packages(loadpackage.sas);' / ; /* for older versions when the SPFinit.sas did not exist */
/* load */
put @n '%loadpackage'"(&packageName.,";
put @n " path=&buildLocation.)" /;
put @n '%loadpackage'"(&packageName.,";
put @n " path=&buildLocation., lazyData=*)" /;
/* help */
put @n '%helpPackage'"(&packageName.,";
put @n " path=&buildLocation.)" /;
put @n '%helpPackage'"(&packageName.,*,";
put @n " path=&buildLocation.)" /;
put @n '%helpPackage'"(&packageName.,License,";
put @n " path=&buildLocation.)" /;
/* preview */
put @n '%previewPackage'"(&packageName.,";
put @n " path=&buildLocation.)" /;
put @n '%previewPackage'"(&packageName.,*,";
put @n " path=&buildLocation.)" /;
/* unload */
put @n '%unloadPackage'"(&packageName.,";
put @n " path=&buildLocation.) " /;
/* additional content */
put @n '%loadPackageAddCnt'"(&packageName.,";
put @n " path=&buildLocation.) " /;
put ;
put '***************************************************';
run;
%GOTO NOTESTING;
%end;
/* locate sas binaries for testing part of the framework */
/**** %local SASROOT SASEXE SASWORK; ****/
%if %superq(sasexe) = %then /* empty value points to the SAS binary file based in the !sasroot directory */
%do;
filename sasroot "!SASROOT";
%let SASROOT=%sysfunc(PATHNAME(sasroot));
filename sasroot;
%put NOTE: &=SASROOT.;
%let SASEXE=&SASROOT./sas;
%end;
%else
%do;
filename sasroot "&SASEXE.";
%if %sysfunc(fexist(sasroot)) %then
%do;
%let SASROOT=%sysfunc(PATHNAME(sasroot));
filename sasroot;
%put NOTE: &=SASROOT.;
%let SASEXE=&SASROOT./sas;
%end;
%else
%do;
%put ERROR: [&sysmacroname.] Provided location of the SAS binary file does not exist!;
%put ERROR- The directory was: &SASEXE.;
%put ERROR- Testing would not be executed.;
filename sasroot;
%GOTO NOTESTING;
%end;
%end;
%if 0 = %sysfunc(fileexist(&SASEXE.)) /* Linux/UNIX */
AND
0 = %sysfunc(fileexist(&SASEXE..exe)) /* WINDOWS */
%then
%do;
%put ERROR: [&sysmacroname.] Provided location of the SAS binary file does not contain SAS file!;
%put ERROR- The file searched was: &SASEXE.;
%put ERROR- Testing would not be executed.;
%GOTO NOTESTING;
%end;
%put NOTE: Location of the SAS binary is:;
%put NOTE- &=SASEXE. ;
%put ;
/* locate sas work */
%let SASWORK=%sysfunc(GETOPTION(work));
%put NOTE: &=SASWORK.;
%put ;
/* location of the config file */
/**** %local SASCONFIG; ****/ /* by default a local macrovariable is empty, so no file would be pointed as a config file */
%if %Qupcase(&sascfgFile.) = DEF %then /* the DEF value points to the sasv9.cfg file in the sasroot directory */
%do;
%let SASCONFIG = -config "&SASROOT./sasv9.cfg";
%put NOTE: The following SAS config file will be used:;
%put NOTE- &=SASCONFIG.;
%end;
%else %if %superq(sascfgFile) NE %then /* non-empty path points to user defined config file */
%do;
%if %sysfunc(fileexist(&sascfgFile.)) %then
%do;
%let SASCONFIG = -config "&SASCFGFILE.";
%put NOTE: The following SAS config file will be used:;
%put NOTE- &=SASCONFIG.;
%end;
%else
%do;
%put ERROR: [&sysmacroname.] Provided SAS config file does not exist!;
%put ERROR- The file was: &SASCFGFILE.;
%put ERROR- Testing would not be executed.;
%GOTO NOTESTING;
%end;
%end;
options DLCREATEDIR; /* turns-on creation of subdirectories by libname */
/* temporary location for tests results is WORK unless developer provide &testResults. */
/**** %local testPackageTimesamp; ****/
%let testPackageTimesamp = %sysfunc(lowcase(&packageName._%sysfunc(datetime(),b8601dt15.)));
%if %qsysfunc(fileexist(%superq(testResults))) %then
%do;
libname TEST "&testResults./test_&testPackageTimesamp.";
%end;
%else
%do;
%if NOT %sysevalf(%superq(testResults)=,boolean) %then
%do;
%put WARNING: The testResults path:;
%put WARNING- %superq(testResults);
%put WARNING- does not exist. WORK will be used.;
%put WARNING- ;
%end;
libname TEST "&SASWORK./test_&testPackageTimesamp.";
%end;
/* test WORK points to the SAS session WORK or to directory pointed by the developer */
%if %qsysfunc(fileexist(%superq(testWorkPath))) %then
%do;
libname TESTWORK "&testWorkPath./testwork_&testPackageTimesamp.";
%put NOTE- ;
%PUT NOTE: WORK libname directories from test SAS sessions will not be deleted.;
%if %sysevalf(1=%superq(workInTestResults),boolean) %then
%do;
%put NOTE- Parameter workInTestResults is ignored;
%end;
%put NOTE- ;
%let delTestWork=0;
%end;
%else %if %sysevalf(1=%superq(workInTestResults),boolean) %then
%do;
libname TESTWORK "%sysfunc(pathname(TEST))";
%put NOTE- ;
%PUT NOTE: WORK libname directories from test SAS sessions will be located in the;
%PUT NOTE- same directory where test resulrs are stored, and will not be deleted.;
%put NOTE- ;
%let delTestWork=0;
%end;
%else
%do;
%if NOT %sysevalf(%superq(testWorkPath)=,boolean) %then
%do;
%put WARNING: The testWorkPath path:;
%put WARNING- %superq(testWorkPath);
%put WARNING- does not exist. WORK will be used.;
%put WARNING- ;
%end;
libname TESTWORK "&SASWORK./testwork_&testPackageTimesamp.";
%end;
/**** %local dirForTest dirForTestWork; ****/
%let dirForTest = %sysfunc(pathname(TEST));
%let dirForTestWork = %sysfunc(pathname(TESTWORK));
%put ;
%put NOTE: &=dirForTest.;
%put NOTE: &=dirForTestWork.;
%put ;
/* remember location of sessions current directory */
filename currdir ".";
filename currdir list;
/* if your package uses any other packages this points to their location */
/* test if packages fileref exists and, if it does, use it */
/* if no one is provided the buildLocation is used as a replacement */
%if %superq(packages)= %then %let packages=%sysfunc(pathname(packages));
%if %superq(packages)= %then %let packages=&buildLocation.;
%put NOTE- ;
%put NOTE: The following location path for packages will be used during the testing:;
%put NOTE- &packages.;
/* filename packages "&packages."; */
/* filename packages list;*/
/* replace current dir with the temporary one for tests */
%put NOTE- ;
%put NOTE: Changing current folder to:;
%put NOTE- *%sysfunc(DLGCDIR(&dirForTest.))*;
/* turn off the note about quoted string length */
%local quotelenmax_tmp;
%let quotelenmax_tmp = %sysfunc(getoption(quotelenmax));
options NOquotelenmax;
/* the first test is for loading package, testing help and unloading */
/*-1-*/
data _null_;
file "./loading.sas";
put "proc printto"
/ "log = '&dirForTest./loading.log0'"
/ "; run;";
put "filename packages '&packages.';" /;
if fileexist("&packages./SPFinit.sas") then
put '%include packages(SPFinit.sas);' /;
else if fileexist("&packages./loadpackage.sas") then
put '%include packages(loadpackage.sas);' / ; /* for older versions when the SPFinit.sas did not exist */
/* load */
put '%loadpackage'"(&packageName.,"
/ " path=&buildLocation.)" /;
put '%loadpackage'"(&packageName.,"
/ " path=&buildLocation., lazyData=*)" /;
/* help */
put '%helpPackage'"(&packageName.,"
/ " path=&buildLocation.)" /;
put '%helpPackage'"(&packageName.,*,"
/ " path=&buildLocation.)" /;
put '%helpPackage'"(&packageName.,License,"
/ " path=&buildLocation.)" /;
/* preview */
put '%previewPackage'"(&packageName.,";
put " path=&buildLocation.)" /;
put '%previewPackage'"(&packageName.,*,";
put " path=&buildLocation.)" /;
/*check if package elements realy exist*/
EOF = 0;
do until(EOF);
set &filesWithCodes. end = EOF;
by type notsorted;
fileshortUP = UPCASE(fileshort); drop fileshortUP;
select;
when (upcase(type) in ("LAZYDATA")) /* the "DATA" type will pop-up during deletion */
do;
if 1 = FIRST.type then
put "data _null_; "
/ " if not exist('" fileshortUP "') then "
/ " put 'WARNING: Dataset " fileshortUP "does not exist!'; " ;
if 1 = LAST.type then
put "run; ";
end;
when (upcase(type) =: "MACRO")
do;
if 1 = FIRST.type then
put "data _null_; "
/ ' if not input(resolve(''%SYSMACEXIST(' fileshortUP ')''), best.) then '
/ " put 'WARNING: Macro " fileshortUP "does not exist!'; " ;
if 1 = LAST.type then
put "run; ";
end;
/* the "FUNCTION" type will pop-up during deletion */
/* figure out checks for remaining list: */
/*
"IMLMODULE"
"PROTO"
"FORMAT"
*/
otherwise;
end;
end;
/* unload */
put '%unloadPackage'"(&packageName.,"
/ " path=&buildLocation.) " /;
/* additional content */
put '%loadPackageAddCnt'"(&packageName.,"
/ " path=&buildLocation.) " /;
put "filename packages '&buildLocation.';"
/ '%listPackages() ' /;
/* check if work should be deleted after test is done */
delTestWork = input(symget('delTestWork'), ?? best32.);
if 0 = delTestWork then
put "options NOWORKTERM;"/;
put "proc printto"
/ "; run;";
stop;
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
-linesize - MAX
-pagesize - MAX
*/
systask kill sas0 wait;
%local sasstat0 TEST_0 TESTRC_0;;
%let TEST_0 = loading;
%local STSK;
%let STSK = systask command
%str(%')"&SASEXE."
-sysin "&dirForTest./&TEST_0..sas"
-print "&dirForTest./&TEST_0..lst"
-log "&dirForTest./&TEST_0..log"
/*-altlog "&dirForTest./&TEST_0..altlog"*/
&SASCONFIG.
-work "&dirForTestWork."
-noterminal
-rsasuser -linesize MAX -pagesize MAX -noautoexec %str(%')
taskname=sas0
status=sasstat0
WAIT
;
%put NOTE: Systask:;
%put NOTE- %superq(STSK);
;
%unquote(&STSK.);
;
%let TESTRC_0 = &SYSRC.;
%put NOTE: &=sasstat0. &=TESTRC_0.;
%local notesSourceOptions;
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
options NOnotes NOsource;
data _null_;
if _N_ = 1 then
put "##########################################################################" /
"./loading.log0" /
"##########################################################################" ;
infile "./loading.log0" dlm='0a0d'x end=EOF;
input;
if _INFILE_ =: 'WARNING:' then
do;
warnings+1;
put _N_= "**" _INFILE_;
end;
if _INFILE_ =: 'ERROR:' then
do;
errors+1;
put _N_= "$$" _INFILE_;
end;
if EOF then
do;
put "##########################################################################" ;
put (_ALL_) (=/ "Number of ");
call symputX("TESTW_0", warnings, "L");
call symputX("TESTE_0", errors, "L");
end;
run;
options &notesSourceOptions.;
/*-1-*/
/* other tests are provided by the developer */
%local numberOfTests;
%let numberOfTests = 0;
data _null_;
/* break if no data */
if NOBS = 0 then stop;
set &filesWithCodes. nobs = NOBS;
if (upcase(type) in: ('TEST')); /* only test files are used */
test + 1; /* count the number of tests */
_RC_ = filename(cats("_TIN_",test), catx("/", base, folder, file));
_RC_ = filename(cats("_TOUT_",test), cats("./", file));
_RC_ = fcopy(cats("_TIN_",test), cats("_TOUT_", test));
call symputX(cats("TEST_", test), fileshort, "L");
call symputX("numberOfTests", test, "L");
_RC_ = filename(cats("_TIN_",test));
_RC_ = filename(cats("_TOUT_",test));
run;
%local t;
%do t = 1 %to &numberOfTests.;
/* each test is executed with autoexec loading the package */
data _null_;
/* break if no data */
if NOBS = 0 then stop;
file "./autoexec.sas";
/* check if work should be deleted after test is done */
delTestWork = input(symget('delTestWork'), ?? best32.);
if not(delTestWork in (0 1)) then
do;
putlog "WARNING: [&sysmacroname.] The `delTestWork` parameter is invalid.";
putlog "WARNING- [&sysmacroname.] Default value (1) is set.";
delTestWork = 1;
end;
if 0 = delTestWork then
do;
put "libname _ '&dirForTest.';" /
"data TESTWORK_&t.;" /
" length testName $ 128 testWork $ 2048;" /
" testNumber=&t.; testName='&&TEST_&t..';" /
" testWork = pathname('WORK');" /
"run;" /
"proc append base=_.TESTWORK data=TESTWORK_&t.; run;" /
"proc delete data=TESTWORK_&t.; run;" /
"libname _ clear;" ;
end;
put "proc printto";
put "log = '&dirForTest./&&TEST_&t...log0'";
put "; run;";
put "filename packages '&packages.';" /;
if fileexist("&packages./SPFinit.sas") then
put '%include packages(SPFinit.sas);' /;
else if fileexist("&packages./loadpackage.sas") then
put '%include packages(loadpackage.sas);' /; /* for older versions when the SPFinit.sas did not exist */
put '%loadpackage'"(&packageName.,";
put " path=&buildLocation.)" /;
put '%loadpackage'"(&packageName.,";
put " path=&buildLocation., lazyData=*)" /;
if 0 = delTestWork then
put "options NOWORKTERM;"/;
/*
put "proc printto";
put "; run;";
*/
stop;
set &filesWithCodes. nobs = NOBS;
run;
systask kill sas&t. wait;
%local sasstat&t. TESTRC_&t;
%let STSK =
systask command
%str(%')"&SASEXE."
-sysin "&dirForTest./&&TEST_&t...sas"
-print "&dirForTest./&&TEST_&t...lst"
-log "&dirForTest./&&TEST_&t...log"
/*-altlog "&dirForTest./&&TEST_&t...altlog"*/
&SASCONFIG.
-work "&dirForTestWork."
-autoexec "&dirForTest./autoexec.sas"
-noterminal
-rsasuser %str(%')
taskname=sas&t.
status=sasstat&t.
WAIT
;
%put NOTE: Systask:;
%put NOTE- %superq(STSK);
;
%unquote(&STSK.);
;
%let TESTRC_&t = &SYSRC.;
%put NOTE- sasstat&t.=&&sasstat&t. TESTRC_&t=&&TESTRC_&t;
%local notesSourceOptions;
%let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source));
options NOnotes NOsource;
data _null_;
if _N_ = 1 then
put "##########################################################################" /
"./&&TEST_&t...log0" /
"##########################################################################" ;
infile "./&&TEST_&t...log0" dlm='0a0d'x end=EOF;
input;
if _INFILE_ =: 'WARNING:' then
do;
warnings+1;
/*length warningline $ 1024;
warningline = catx(',', strip(warningline), _N_);*/
put _N_= "**" _INFILE_;
end;
if _INFILE_ =: 'ERROR:' then
do;
errors+1;
/*length errorline $ 1024;
errorline = catx(',', strip(errorline), _N_);*/
put _N_= "$$" _INFILE_;
end;
if EOF then
do;
put "##########################################################################" ;
put (_ALL_) (=/ "Number of ");
call symputX("TESTW_&t.", warnings, "L");
call symputX("TESTE_&t.", errors, "L");
end;
run;
options &notesSourceOptions.;
%end;
data test.tests_summary;
length testName $ 128;
do testNumber = 0 to &numberOfTests.;
testName = symget(cats("TEST_", testNumber));
systask = coalesce(input(symget(cats("SASSTAT", testNumber)), ?? best32.), -1);
sysrc = coalesce(input(symget(cats("TESTRC_", testNumber)), ?? best32.), -1);
error = coalesce(input(symget(cats("TESTE_", testNumber)), ?? best32.), -1);
warning = coalesce(input(symget(cats("TESTW_", testNumber)), ?? best32.), -1);
output;
end;
run;
title1 "Summary of tests.";
title2 "details can be found in:";
title3 "%sysfunc(pathname(TEST))";
footnote;
proc print data = test.tests_summary(drop=testNumber);
run;
title;
%if 0=&delTestWork. %then
%do;
data test.tests_summary;
merge
test.tests_summary
%if %sysfunc(EXIST(test.testwork)) %then
%do; test.testwork %end;
%else
%do; %PUT INFO: Cannot add work path location info.; %end;
;
by testNumber;
run;
%if %sysfunc(EXIST(test.testwork)) %then
%do;
proc delete data=test.testwork;
run;
%end;
%end;
/*%put _local_;*/
%put NOTE: Changing current folder to:;
%put NOTE- *%sysfunc(DLGCDIR(%sysfunc(pathname(currdir))))*;
filename CURRDIR clear;
/* turn on the original value of the note about quoted string length */
options &quotelenmax_tmp.;
/* if you do not want any test to be executed */
%NOTESTING:
/*=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/
%end;
%else
%do;
%put INFO: SAS Packages Framework internal macro. Executable only inside the %nrstr(%%)generatePackage() macro.;
%end;
%mend SPFint_gnPckg_tests;

View File

@@ -8,12 +8,12 @@
,nobs=0 /* technical parameter */
)
/*** HELP END ***/
/ des = 'Utility macro to split "one big" code into multiple files for a SAS package, version 20251221. Run %splitCodeForPackage() for help info.'
/ des = 'Utility macro to split "one big" code into multiple files for a SAS package, version 20251231. Run %splitCodeForPackage() for help info.'
;
%if (%superq(codeFile) = ) OR (%qupcase(&codeFile.) = HELP) %then
%do;
%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))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -24,7 +24,7 @@
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Utility macro to *split* single file with SAS package code into multiple #;
%put # files with separate snippets, version `20251221` #;
%put # files with separate snippets, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -69,15 +69,15 @@
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
%put ;
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 01_macro(abc) */ );
%put %nrstr( %%macro abc(); );
%put %nrstr( %%)%nrstr(macro abc(); );
%put %nrstr( %%put I am "abc".; );
%put %nrstr( %%mend abc; );
%put %nrstr( %%)%nrstr(mend abc; );
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 01_macro(abc) */ );
%put ;
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 01_macro(efg) */ );
%put %nrstr( %%macro efg(); );
%put %nrstr( %%)%nrstr(macro efg(); );
%put %nrstr( %%put I am "efg".; );
%put %nrstr( %%mend efg; );
%put %nrstr( %%)%nrstr(mend efg; );
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 01_macro(efg) */ );
%put ;
%put %nrstr( proc FCMP outlib=work.f.p; );
@@ -400,7 +400,7 @@ options nomprint nosymbolgen nomlogic notes source ls=MAX ps=MAX msglevel=N ;
*/
if firstLine[j] then
do;
put '/* File generated with help of SAS Packages Framework, version 20251221. */';
put '/* File generated with help of SAS Packages Framework, version 20251231. */';
firstLine[j]=0;
end;
put _infile_;

View File

@@ -0,0 +1,391 @@
/*+unbundlePackages+*/
%macro unbundlePackages(
bundleName
,path=
,pathRef=
,packagesPath=
,packagesRef=packages
,ods= /* data set for report file */
,verify=0
)/
des='Macro to extract a bundle of SAS packages, version 20251231. Run %unbundlePackages(HELP) for help info.'
secure
minoperator
;
%if (%superq(bundleName) = ) OR (%qupcase(&bundleName.) = 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 `unbundlePackages` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *extract* SAS packages from a bundle, version `20251231` #;
%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(%%unbundlePackages())` macro allows to extract SAS packages from #;
%put # a bundle into a single directory. #;
%put # #;
%put #-------------------------------------------------------------------------------#;
%put #### Parameters: #;
%put # #;
%put # 1. `bundleName` *Required.* Name of a bundle, e.g. myBundle, #;
%put # extension `.bundle.zip` is automatically added. #;
%put # For empty value or `HELP` this help information #;
%put # is displayed. #;
%put # #;
%put # - `path=` *Required.* Location of the bundle. Must be a valid #;
%put # directory. Takes precedence over `pathRef` parameter. #;
%put # Either `path=` or `pathRef=` must be non-empty. #;
%put # #;
%put # - `pathRef=` *Optional.* Fileref to location of the bundle. #;
%put # Either `path=` or `pathRef=` must be non-empty. #;
%put # #;
%put # - `packagesPath=` *Optional.* Location for packages extracted from #;
%put # the bundle. Takes precedence over `packagesRef`. #;
%put # When non-empty, must be a valid directory. #;
%put # #;
%put # - `packagesRef=` *Optional.* Fileref to location where packages will #;
%put # be extracted. Default value is `packages`. #;
%put # #;
%put # - `ods=` *Optional.* Name of SAS data set for the report. #;
%put # #;
%put # - `verify=` *Optional.* Indicates if verification code should #;
%put # be executed after bundle extraction. #;
%put # Value `1` means yes, Value `0` means no. #;
%put # #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
%put # to learn more. #;
%put # Tutorials available at: `https://github.com/yabwon/HoW-SASPackages` #;
%put # #;
%put ### Example 1 ###################################################################;
%put # #;
%put # Enabling the SAS Package Framework #;
%put # from the local directory and extract a bundle of #;
%put # packages from user home directory to packages. #;
%put # #;
%put # Assume that the `SPFinit.sas` file #;
%put # is located in the "/sas/PACKAGES/" folder. #;
%put # #;
%put # Run the following code in your SAS session: #;
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
%put %nrstr( filename packages "/sas/PACKAGES/"; %%* setup a directory for packages;);
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
%put ;
%put %nrstr( %%unbundlePackages%(myLittleBundle );
%put %nrstr( ,path=/home/user/bundles );
%put %nrstr( ,verify=1 );
%put %nrstr( ,packagesRef=PACKAGES%) );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put # #;
%put #################################################################################;
%put ;
options &options_tmp.;
%GOTO ENDofunbundlePackages;
%end;
/* local variables for options */
%local ls_tmp ps_tmp notes_tmp source_tmp stimer_tmp fullstimer_tmp msglevel_tmp mautocomploc_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));
%let mautocomploc_tmp = %sysfunc(getoption(mautocomploc));
options NOnotes NOsource ls=128 ps=MAX NOfullstimer NOstimer msglevel=N NOmautocomploc;
/*===================================================================================================*/
%if NOT(%superq(verify) in (0 1)) %then %let verify=0;
%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;
%local reportFile datetime;
%let datetime = %sysfunc(datetime());
%let reportFile = WORK.tmpbundlefile%sysfunc(int(&datetime.), b8601dt15.)_;
data _null_ ;
datetime=symgetn('datetime');
length packagesList $ 32767 bundleName $ 128;
bundleName = compress(symget('bundleName'),"_.","KAD"); /* bundle name is letters, digits, and underscore, up to 128 symbols */
if bundleName NE symget('bundleName') then /* warn about illegal characters */
do;
put "ERROR: Bundle name contains illegal characters. Exiting";
stop;
end;
bundleName=lowcase(bundleName);
/* if there is ".bundle.zip" extension added, remove it */
if substr(strip(reverse(bundleName)),1,11) = 'piz.eldnub.' then bundleName=scan(bundleName,-3,".");
else /* if there is ".bundle" extension added, remove it */
if substr(strip(reverse(bundleName)),1,7) = 'eldnub.' then bundleName=scan(bundleName,-2,".");
put / "INFO: Bundle name is: " bundleName / ;
length packagesPath $ 32767 packagesRef $ 8;
packagesPath = dequote(symget('packagesPath'));
packagesRef = upcase(strip(symget('packagesRef')));
/* organize target path (location for packages) */
if " "=packagesPath then
do;
if 0 then set SASHELP.VEXTFL(keep=level xpath xengine fileref exists);
DECLARE HASH sH(dataset:'SASHELP.VEXTFL(where=(fileref=' !! quote(packagesRef) !! '))', ordered: "A");
sH.DefineKey("level");
sH.DefineData("xpath","xengine","exists");
sH.DefineDone();
if sH.NUM_ITEMS=0 then
do;
put "ERROR: Fileref in packagesRef= does NOT exist. Exiting!";
stop;
end;
packagesPath=" ";
rc = sH.FIND(key:NOT(1=sH.NUM_ITEMS)); /* if only 1 element select level 0, if more than 1 select level 1 */
if xengine = "DISK" AND exists='yes' then
packagesPath=quote(strip(xpath)); /* add quotes to the packagesPath */
else
do;
put "ERROR: Path: " xpath "in packagesRef= is invalid! Exiting!";
stop;
end;
end;
else
do;
rcPckPath = fileexist(strip(packagesPath));
if 0=rcPckPath then
do;
put "ERROR: Path in packagesPath= does NOT exist. Exiting!";
stop;
end;
else packagesPath=quote(strip(packagesPath)); /* add quotes to the packagesPath */
end;
length path $ 32767 pathRef $ 8;
path = dequote(symget('path'));
pathRef = upcase(strip(symget('pathRef')));
if " "=path and " "=pathRef then
do;
put "ERROR: Path= and pathRef= are empty! Exiting!";
stop;
end;
/* verify source path (location of the bundle) */
if " "=path then
do;
DECLARE HASH tH(dataset:'SASHELP.VEXTFL(where=(fileref=' !! quote(pathRef) !! '))', ordered: "A");
tH.DefineKey("level");
tH.DefineData("xpath","xengine","exists");
tH.DefineDone();
DECLARE HITER tI("tH");
do while (tI.next()=0);
put "Checking in: " xpath;
if fileexist(cats(xpath,"/",bundleName,'.bundle.zip')) then
do;
path=strip(xpath);
put "INFO: Bundle file " bundleName +(-1) ".bundle.zip found under: " xpath;
leave;
end;
end;
if " "=path then
do;
put "ERROR: Bundle: " bundleName "does NOT exist in any directory in pathRef=. Exiting!";
stop;
end;
end;
else
do;
rcPath = fileexist(strip(path));
if 0=rcPath then
do;
put "ERROR: Path in Path= does NOT exist. Exiting!";
stop;
end;
end;
/* get the list of packages to unbundle from bundlecontent.sas */
length bundlecontentFR $ 8;
rc1 = filename(bundlecontentFR, cats(path,"/",bundleName,'.bundle.zip'));
rcE = fexist(bundlecontentFR);
rc2 = filename(bundlecontentFR);
if 0=rcE then
do;
put "ERROR: The " bundleName "file does NOT exist!. Exiting!";
stop;
end;
length bundlecontentFR $ 8;
rc1 = filename(bundlecontentFR, cats(path,"/",bundleName,'.bundle.zip'), 'zip', 'member="bundlecontent.sas"');
rcE = fexist(bundlecontentFR);
rc2 = filename(bundlecontentFR);
if 0=rcE then
do;
put "ERROR: The bundlecontent.sas file does NOT exist inside bundle. Exiting!";
stop;
end;
length bundlecontentfile $ 1024;
bundlecontentfile = cats(path,"/",bundleName,'.bundle.zip');
infile _DUMMY_ ZIP FILEVAR=bundlecontentfile member="bundlecontent.sas" end=EOF dlm=",";
DECLARE HASH Q(ordered:"A");
Q.defineKey("package");
Q.defineData("package",'pckVer','pckDtm','hash');
Q.defineDone();
DECLARE HITER IQ("Q");
/*--------------------------------------------------*/
do until(EOF);
input package :$32. pckVer :$16. pckDtm :$16. hash :$128.;
if " " NE package then rc = Q.ADD();
end;
label package="Package name"
pckVer="Version"
pckDtm="Generation timestamp"
hash="SHA256 for the Package";
/*--------------------------------------------------*/
if 0=Q.NUM_ITEMS then /* ... if empty then exit */
do;
put "WARNING: No packages to unbundle. Exiting!";
stop;
end;
else
do while(iQ.next()=0);
packagesList = catx(" ", packagesList, package);
end;
rc = Q.output(dataset:"&reportFile.1");
/* code executed for unbundling */
length code1 code2 $ 32767;
code1=
'options ps=min nofullstimer nostimer msglevel=N; filename PACKAGES ' !! strip(packagesPath) !! ';' !!
'%relocatePackage(' !! strip(packagesList) !! ',source=' !! catx("/", path, bundleName) !!
'.bundle.zip, sDevice=ZIP,psMAX=MIN)';
/*put code=;*/
put / "INFO: The " bundleName "bundle extraction in progress...";
rc = doSubL(code1);
put / "INFO: The " bundleName "bundle extraction ended.";
/* code executed for verification */
%if 1=&verify. %then
%do;
put / "INFO: The " bundleName "bundle verification in progress...";
code2=
'options ps=min nofullstimer nostimer msglevel=N; filename PACKAGES ' !! strip(packagesPath) !! ';' !!
'filename _ ZIP ' !! quote(cats(path, "/", bundleName, ".bundle.zip")) !! ';' !!
'%include _(verification.sas);%listPackages()';
rc = doSubL(code2);
put / "INFO: The " bundleName "bundle verification ended.";
%end;
put " ";
rc=sleep(1,1);
rc = doSubL("title 'Summary of the extracted bundle file';" !!
"proc print data=" !!
%if %superq(ods) NE %then
%do; "%scan(&ods.,1,())" %end;
%else
%do; "&reportFile.1" %end; !!
" label; var package pckVer pckDtm hash; run;" !!
%if %superq(ods) NE %then
%do; %put INFO: Report file: %scan(&ods.,1,()); %end;
%else
%do; "proc delete data=&reportFile.1; run;" %end; !!
"title;");
stop;
run;
/*===================================================================================================*/
/* restore optionos */
options ls = &ls_tmp. ps = &ps_tmp.
&notes_tmp. &source_tmp.
&stimer_tmp. &fullstimer_tmp.
msglevel=&msglevel_tmp. &mautocomploc_tmp.;
%ENDofunbundlePackages:
%mend unbundlePackages;
/*
options mprint;
%unbundlePackages(
bundlenametest123
,path=R:\
,packagesPath=R:\check
,verify=1
)
%unbundlePackages(
bundlenametest124
,path=R:\
,packagesPath=R:\check2
,verify=1
)
%unbundlePackages(
bundlenametest124.bundle.zip
,path=R:\
,packagesPath=R:\check3
)
%unbundlePackages(
bundlenametest124.bundle.zip
,path=R:\
,packagesPath=R:\check4
)
%unbundlePackages()
%unbundlePackages(
nobundlenametest123
,path=R:\
,packagesPath=R:\check
,verify=1
)
*/
/* end of SPFinit.sas file */

View File

@@ -20,12 +20,12 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to unload SAS package, version 20251221. Run %unloadPackage() for help info.'
des = 'Macro to unload SAS package, version 20251231. Run %unloadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
%local options_tmp ;
%let options_tmp = ls=%sysfunc(getoption(ls))ps=%sysfunc(getoption(ps))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -35,7 +35,7 @@ des = 'Macro to unload SAS package, version 20251221. Run %unloadPackage() for h
%put ### This is short help information for the `unloadPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to unload SAS packages, version `20251221` #;
%put # Macro to unload SAS packages, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -13,12 +13,12 @@
hashing_file() function, SAS 9.4M6 */
)/secure
/*** HELP END ***/
des = 'Macro to verify SAS package with the hash digest, version 20251221. Run %verifyPackage() for help info.'
des = 'Macro to verify SAS package with the hash digest, version 20251231. 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))
%let options_tmp = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
msglevel=%sysfunc(getoption(msglevel))
;
@@ -28,7 +28,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20251221. Run %
%put ### This is short help information for the `verifyPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to verify SAS package with it hash digest, version `20251221` #;
%put # Macro to verify SAS package with it hash digest, version `20251231` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -96,7 +96,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20251221. Run %
options NOnotes NOsource ls=MAX ps=MAX NOfullstimer NOstimer msglevel=N NOmautocomploc;
%local _PackageFileref_;
%local _PackageFileref_ checkExist;
data _null_;
call symputX("_PackageFileref_", "P" !! put(MD5(lowcase("&packageName.")), hex7. -L), "L");
run;
@@ -109,17 +109,18 @@ des = 'Macro to verify SAS package with the hash digest, version 20251221. Run %
if char(packages,1) ^= "(" then packages = quote(strip(packages)); /* for paths with spaces */
do i = 1 to kcountw(packages, "()", "QS");
p = dequote(kscanx(packages, i, "()", "QS"));
exists + fileexist(catx("/", p, lowcase("&packageName.") !! "zip")); /* check on zip files only! */
exists + fileexist(catx("/", p, lowcase("&packageName.") !! ".zip")); /* check on zip files only! */
if exists then leave;
end;
if exists then call symputx("path", p, "L");
else call symputx("checkExist", '0 AND', "L");
run;
filename &_PackageFileref_.
/* put location of package myPackageFile.zip here */
"&path./%sysfunc(lowcase(&packageName.)).zip"
;
%if %sysfunc(fexist(&_PackageFileref_.)) %then
%if &checkExist. %sysfunc(fexist(&_PackageFileref_.)) %then
%do;
/* create hash SHA256 id *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
%local HASHING_FILE_exist;
@@ -141,7 +142,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20251221. Run %
filename &_PackageFileref_. list;
data _null_;
length providedHash $ 100;
length providedHash $ 128;
providedHash = strip(symget("hash"));
select;
when ( 'F*' = upcase(substr(providedHash,1,2)) ) /* F = file digest */

View File

@@ -1,7 +1,7 @@
---
# SAS Packages Framework, version `20251221`
# SAS Packages Framework, version `20251231`
---
@@ -21,6 +21,8 @@
* [the `relocatePackage` macro](#relocatepackage)
* [the `isPackagesFilerefOK` macro](#ispackagesfilerefok)
* [the `SasPackagesFrameworkNotes` macro](#saspackagesframeworknotes)
* [the `bundlePackages` macro](#bundlepackages)
* [the `unbundlePackages` macro](#unbundlepackages)
* [Some more examples](#some-more-examples)
--------------------------------------------------------------------------------------------
@@ -32,7 +34,7 @@ A **SAS package** is an automatically generated, single, stand alone *zip* file
The *purpose of a package* is to be a simple, and easy to access, code sharing medium, which will allow: on the one hand, to separate the code complex dependencies created by the developer from the user experience with the final product and, on the other hand, reduce developer's and user's unnecessary frustration related to a remote deployment process.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20251221`**.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20251231`**.
**To get started with SAS Packages** try this [**`Introduction to SAS Packages`**](https://youtube.com/playlist?list=PLeMzGEImIT5eV13IGXQIgWmTFCJt_cLZG&si=ElQm0_ifq76mvUbq "Introduction to SAS Packages video series") video series or [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
@@ -55,7 +57,7 @@ them using the SPF can be found [**HERE**](https://github.com/yabwon/HoW-SASPack
## This is short help information for the `installPackage` macro <a name="installpackage"></a>
--------------------------------------------------------------------------------------------
Macro to install SAS packages, version `20251221`
Macro to install SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -183,7 +185,7 @@ filename packages "C:/SAS_PACKAGES";
## This is short help information for the `helpPackage` macro <a name="helppackage"></a>
-------------------------------------------------------------------------------
Macro to get help about SAS packages, version `20251221`
Macro to get help about SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -261,7 +263,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `loadPackage` macro <a name="loadpackage"></a>
-------------------------------------------------------------------------------
Macro to *load* SAS packages, version `20251221`
Macro to *load* SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -419,7 +421,7 @@ If created, those macros are automatically deleted when the `%unloadPackage()` m
## This is short help information for the `loadPackageS` macro <a name="loadpackages"></a>
-------------------------------------------------------------------------------
Macro wrapper for the loadPackage macro, version `20251221`
Macro wrapper for the loadPackage macro, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -470,7 +472,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `unloadPackage` macro <a name="unloadpackage"></a>
-------------------------------------------------------------------------------
Macro to unload SAS packages, version `20251221`
Macro to unload SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -537,7 +539,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `listPackages` macro <a name="listpackages"></a>
-----------------------------------------------------------------------------------------
Macro to list available SAS packages, version `20251221`
Macro to list available SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -580,7 +582,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `verifyPackage` macro <a name="verifypackage"></a>
-------------------------------------------------------------------------------
Macro to verify SAS package with it hash digest, version `20251221`
Macro to verify SAS package with it hash digest, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -634,7 +636,7 @@ filename packages "C:/SAS_PACKAGES"; %* set-up a directory for packages;
## This is short help information for the `previewPackage` macro <a name="previewpackage"></a>
-------------------------------------------------------------------------------
Macro to get preview of a SAS packages, version `20251221`
Macro to get preview of a SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -703,7 +705,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `generatePackage` macro <a name="generatepackage"></a>
-------------------------------------------------------------------------------
Macro to generate SAS packages, version `20251221`
Macro to generate SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -727,6 +729,10 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
`%generatePackage(filesLocation=/path/to/packagename)`
If empty displays this help information.
- `buildLocation=` Points to a location where the ZIP file with the package
should be generated. If the value is null (default)
the `filesLocation=` value is used.
Testing parameters:
- `testPackage=` Indicator if tests should be executed.
@@ -777,6 +783,8 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
The default value: `0` means "do not create files".
Available values are `0` and `1`.
- `archLocation=` Location for versioned package ZIP file (if `easyArch=1`)
If empty (default) the `buildLocation` value is used.
-------------------------------------------------------------------------------
@@ -930,7 +938,7 @@ All files have to have `.sas` extension. Other files are ignored.
## This is short help information for the `extendPackagesFileref` macro <a name="extendpackagesfileref"></a>
-----------------------------------------------------------------------------------------
Macro to list directories pointed by 'packages' fileref, version `20251221`
Macro to list directories pointed by 'packages' fileref, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -972,7 +980,7 @@ filename packages ("D:/NEW_DIR" %extendPackagesFileref()); %* add new directory;
## This is short help information for the `loadPackageAddCnt` macro <a name="loadpackageaddcnt"></a>
-------------------------------------------------------------------------------
Macro to load *additional content* for a SAS package, version `20251221`
Macro to load *additional content* for a SAS package, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1066,7 +1074,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
-------------------------------------------------------------------------------
Utility macro to *split* single file with SAS package code into multiple
files with separate snippets, version `20251221`
files with separate snippets, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1147,7 +1155,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `relocatePackage` macro <a name="relocatepackage"></a>
-------------------------------------------------------------------------------
Macro to *locally copy or move* (relocate) SAS packages, version `20251221`
Macro to *locally copy or move* (relocate) SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1259,7 +1267,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `isPackagesFilerefOK` macro <a name="ispackagesfilerefok"></a>
-----------------------------------------------------------------------------------------
Macro to check if the `packages` fileref is "correct", version `20251221`
Macro to check if the `packages` fileref is "correct", version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1310,7 +1318,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `SasPackagesFrameworkNotes` macro <a name="saspackagesframeworknotes"></a>
-------------------------------------------------------------------------------
Macro prints help notes for SAS Packages Framework macros, version `20251221`
Macro prints help notes for SAS Packages Framework macros, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1357,6 +1365,142 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `bundlePackages` macro <a name="bundlepackages"></a>
-------------------------------------------------------------------------------
Macro to *create bundles* of SAS packages, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and included by
a single `load.sas` file (also embedded inside the zip).
The `%bundlePackages()` macro allows to bundle a bunch of SAS packages
into a single file (a SAS packages bundle), just like a snapshot.
-------------------------------------------------------------------------------
### Parameters:
1. `bundleName` *Required.* Name of a bundle, e.g. myBundle,
if the value is empty a default name is generated:
`saspackagesbundle_createdYYYYMMDDtHHMMSS`, an
extension `.bundle.zip` is automatically added.
For value `HELP` this help information is displayed.
- `path=` *Required.* Location of the bundle. Must be a valid
directory. Takes precedence over `pathRef` parameter.
Either `path=` or `pathRef=` must be non-empty.
- `pathRef=` *Optional.* Fileref to location of the bundle.
Either `path=` or `pathRef=` must be non-empty.
- `packagesList=` *Optional.* A space-separated list of packages
to bundle. If the value is empty all available
packages are used.
- `packagesPath=` *Optional.* Location of packages for the bundle.
Takes precedence over `packagesRef` parameter.
When non-empty, must be a valid directory.
- `packagesRef=` *Optional.* Fileref to location of packages for the
bundle. Default value is `packages`.
- `ods=` *Optional.* Name of SAS data set for the report.
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation`
to learn more.
Tutorials available at: `https://github.com/yabwon/HoW-SASPackages`
### Example 1 ##################################################################
Enabling the SAS Package Framework
from the local directory and create a bundle of
selected packages in user home directory.
Assume that the `SPFinit.sas` file
is located in the "/sas/PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "/sas/PACKAGES/"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%bundlePackages(myLittleBundle
,path=/home/user/bundles
,packagesList=basePlus SQLinDS macroarray
,packagesRef=PACKAGES)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `unbundlePackages` macro <a name="unbundlepackages"></a>
-------------------------------------------------------------------------------
Macro to *extract* SAS packages from a bundle, version `20251231`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and included by
a single `load.sas` file (also embedded inside the zip).
The `%unbundlePackages()` macro allows to extract SAS packages from
a bundle into a single directory.
-------------------------------------------------------------------------------
### Parameters:
1. `bundleName` *Required.* Name of a bundle, e.g. myBundle,
extension `.bundle.zip` is automatically added.
For empty value or `HELP` this help information
is displayed.
- `path=` *Required.* Location of the bundle. Must be a valid
directory. Takes precedence over `pathRef` parameter.
Either `path=` or `pathRef=` must be non-empty.
- `pathRef=` *Optional.* Fileref to location of the bundle.
Either `path=` or `pathRef=` must be non-empty.
- `packagesPath=` *Optional.* Location for packages extracted from
the bundle. Takes precedence over `packagesRef`.
When non-empty, must be a valid directory.
- `packagesRef=` *Optional.* Fileref to location where packages will
be extracted. Default value is `packages`.
- `ods=` *Optional.* Name of SAS data set for the report.
- `verify=` *Optional.* Indicates if verification code should
be executed after bundle extraction.
Value `1` means yes, Value `0` means no.
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation`
to learn more.
Tutorials available at: `https://github.com/yabwon/HoW-SASPackages`
## Example 1 ##################################################################
Enabling the SAS Package Framework
from the local directory and extract a bundle of
packages from user home directory to packages.
Assume that the `SPFinit.sas` file
is located in the "/sas/PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "/sas/PACKAGES/"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%unbundlePackages(myLittleBundle
,path=/home/user/bundles
,verify=1
,packagesRef=PACKAGES)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff