diff --git a/LICENSE b/LICENSE index aea626e..549dec3 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 70f168e..7969a50 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf b/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf index 9a1eb30..d39f718 100644 Binary files a/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf and b/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf differ diff --git a/SPF/Documentation/SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf b/SPF/Documentation/SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf index ba9ca2d..23776b0 100644 Binary files a/SPF/Documentation/SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf and b/SPF/Documentation/SAS(r) packages - the way to share (a how to)- Paper 4725-2020 - extended.pdf differ diff --git a/SPF/Macros/bundlePackages.sas b/SPF/Macros/bundlePackages.sas new file mode 100644 index 0000000..d7213d5 --- /dev/null +++ b/SPF/Macros/bundlePackages.sas @@ -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. + ¬es_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() +*/ + + diff --git a/SPF/Macros/extendpackagesfileref.sas b/SPF/Macros/extendpackagesfileref.sas index d6321ac..5bc7e3e 100644 --- a/SPF/Macros/extendpackagesfileref.sas +++ b/SPF/Macros/extendpackagesfileref.sas @@ -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 #; diff --git a/SPF/Macros/generatepackage.sas b/SPF/Macros/generatepackage.sas index 190cd25..fb0ed92 100644 --- a/SPF/Macros/generatepackage.sas +++ b/SPF/Macros/generatepackage.sas @@ -3,7 +3,7 @@ Macro to generate SAS packages. - Version 20251221 + Version 20251231 A SAS package is a zip file containing a group of SAS codes (macros, functions, data steps generating @@ -18,7 +18,9 @@ %macro generatePackage( filesLocation /* location of package files - e.g. /path/to/package/files/locatiion or C:\my\package\files */ + e.g. /path/to/package/files/location or C:\my\package\files */ +,buildLocation= /* location of package ZIP file and md (optional) + when empty takes filesLocation */ /* testing options: */ ,testPackage=Y /* indicator if tests should be executed, default value Y means "execute tests" */ @@ -47,9 +49,11 @@ ,easyArch=0 /* when creating documentation file indicates if a copy of the zip and markdown files with the version number in the file name be created */ +,archLocation= /* location for package ZIP files and md (optional) archive + when empty takes buildLocation */ )/ secure minoperator /*** HELP END ***/ -des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() for help info.' +des = 'Macro to generate SAS packages, version 20251231. Run %generatePackage() for help info.' ; %if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then %do; @@ -64,7 +68,7 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put ### This is short help information for the `generatePackage` macro #; %put #------------------------------------------------------------------------------------#; %put # #; - %put # Macro to generate SAS packages, version `20251221` #; + %put # Macro to generate 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 #; @@ -89,6 +93,10 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put # `%nrstr(%%generatePackage(filesLocation=/path/to/packagename))` #; %put # If empty displays this help information. #; %put # #; + %put # - `buildLocation=` Points to a location where the ZIP file with the package #; + %put # should be generated. If the value is null (default) #; + %put # the `filesLocation=` value is used. #; + %put # #; %put # Testing parameters: #; %put # #; %put # - `testPackage=` Indicator if tests should be executed. #; @@ -139,6 +147,9 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put # The default value: `0` means "do not create files". #; %put # Available values are `0` and `1`. #; %put # #; + %put # - `archLocation=` Location for versioned package ZIP file (if `easyArch=1`) #; + %put # If empty (default) the `buildLocation` value is used. #; + %put # #; %put #------------------------------------------------------------------------------------#; %put ######################################################################################; %put ; @@ -155,7 +166,44 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_; %let _DESCR_ = _%sysfunc(datetime(), hex6.)d; %let _LIC_ = _%sysfunc(datetime(), hex6.)l; -%let _DUMMY_ = _%sysfunc(datetime(), hex6.)_; +%let _DUMMY_ = d%sysfunc(datetime(), hex6.)d; + +/* Verify source existence */ +%if 0=%sysfunc(FILEEXIST(%superq(filesLocation))) %then + %do; + %put ERROR: The %superq(filesLocation) directory does NOT exist!; + %put ERROR- Aborting.; + %abort; + %end; + +/* Determine build location for ZIP and MD(optional) */ +/* Priority: 1. buildLocation, 2. filesLocation */ +/* The buildLocation is used for testing too! */ +%if %sysevalf(%superq(buildLocation)=,boolean) %then + %do; + %let buildLocation = &filesLocation.; + %end; +%else + %do; + %if 0=%sysfunc(FILEEXIST(%superq(buildLocation))) %then + %do; + %put WARNING: The %superq(buildLocation) directory does NOT exist!; + %put WARNING- ; + %put WARNING- The %superq(filesLocation) directory will be used.; + %let buildLocation = &filesLocation.; + %end; + %end; +%put NOTE: Build location is: %superq(buildLocation).; + +data _null_; + length path $ 4096; + do x='filesLocation','buildLocation'; + path = symget(x); + str = kcompress(path,'({[<_ !@#$%^&*-=+/\?"'';:|~`>]})','pdfs'); + if str NE " " then put "NOTE: There are non-ASCII characters in the " x "path: " str + / "NOTE- If you are working with SAS9.4M7 or earlier it may cause problems."; + end; +run; /* collect package metadata from the description.sas file */ filename &_DESCR_. "&filesLocation./description.sas" lrecl = 1024; @@ -303,11 +351,11 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024; if tryExcept then do; - put 'ERROR: Your Required list seems to be problematic.'; - put 'ERROR- Check the description.sas file.'; - put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.'; - put 'ERROR- "SAS Component1", "SAS Component2", "SAS Component3"'; - put 'ERROR- Provided value is:'; + put 'ERROR: Your Required list seems to be problematic.' + / 'ERROR- Check the description.sas file.' + / 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.' + / 'ERROR- "SAS Component1", "SAS Component2", "SAS Component3"' + / 'ERROR- Provided value is:'; length R $ 32767; R = symget('packageRequired'); put 'ERROR- ' R; @@ -353,11 +401,11 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024; if tryExcept then do; - put 'ERROR: Your ReqPackages list seems to be problematic.'; - put 'ERROR- Check the description.sas file.'; - put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.'; - put 'ERROR- "Package1 (X.X)", "Package2 (Y.Y)", "Package3 (Z.Z)"'; - put 'ERROR- Provided value is:'; + put 'ERROR: Your ReqPackages list seems to be problematic.' + / 'ERROR- Check the description.sas file.' + / 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.' + / 'ERROR- "Package1 (X.X)", "Package2 (Y.Y)", "Package3 (Z.Z)"' + / 'ERROR- Provided value is:'; length R $ 32767; R = symget('packageReqPackages'); put 'ERROR- ' R; @@ -407,27 +455,27 @@ data _null_; ; if not (version > 0) then do; - put 'ERROR: Package version should be a positive NUMBER.'; - put 'ERROR- Current value is: ' "&packageVersion."; - put 'ERROR- Try something small, e.g. 0.1'; - put 'ERROR- Aborting.'; + put 'ERROR: Package version should be a positive NUMBER.' + / 'ERROR- Current value is: ' "&packageVersion." + / 'ERROR- Try something small, e.g. 0.1' + / 'ERROR- Aborting.'; put; abort; end; run; /* create or replace the ZIP file for package */ -filename &zipReferrence. ZIP "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; +filename &zipReferrence. ZIP "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; %if %sysfunc(fexist(&zipReferrence.)) %then %do; - %put NOTE: Deleting file "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; + %put NOTE: Deleting file "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; %let _RC_ = %sysfunc(fdelete(&zipReferrence.)); %put NOTE: &=_RC_; %end; %if %sysfunc(fexist(&zipReferrence.)) %then %do; - %put ERROR: File "&filesLocation./%sysfunc(lowcase(&packageName.)).zip" cannot be deleted.; + %put ERROR: File "&buildLocation./%sysfunc(lowcase(&packageName.)).zip" cannot be deleted.; %put ERROR- Check if the file is not blocked by another process.; %put ERROR- Aborting.; %abort; @@ -596,7 +644,9 @@ data &filesWithCodes.; putlog "NOTE: Generating content dataset: &filesWithCodes.."; putlog "NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; putlog "NOTE- "; - base = "&filesLocation."; + base = "&filesLocation."; /* location for source */ + build = "&buildLocation."; /* location for ZIP */ + length folder file lowcase_name $ 256 folderRef fileRef $ 8; drop lowcase_name; @@ -660,8 +710,8 @@ data &filesWithCodes.; file = dread(fileId, j); if file NE lowcase(file) then do; - put 'ERROR: File with code should be named ONLY with low case letters.'; - put 'ERROR- Current value is: ' file; + put 'ERROR: File with code should be named ONLY with low case letters.' + / 'ERROR- Current value is: ' file; lowcase_name = lowcase(file); put 'ERROR- Try to use: ' lowcase_name; put; @@ -673,9 +723,9 @@ data &filesWithCodes.; if strip(reverse(file)) in: ('sas.') then output; /* ignore not ".sas" files */ else do; - put "WARNING: Only *.sas files are supported." / - "WARNING- The file: " file "will be ignored." / - "WARNING- "; + put "WARNING: Only *.sas files are supported." + / "WARNING- The file: " file "will be ignored." + / "WARNING- "; end; end; else @@ -685,10 +735,10 @@ data &filesWithCodes.; additionalContent+1; if additionalContent > 1 then do; - put "WARNING: Only ONE directory with additional content is allowed!" / - "WARNING- Store all additional content in a single directory." / - "WARNING- The directory: " folder "will be ignored." / - "WARNING- "; + put "WARNING: Only ONE directory with additional content is allowed!" + / "WARNING- Store all additional content in a single directory." + / "WARNING- The directory: " folder "will be ignored." + / "WARNING- "; end; else do; @@ -769,11 +819,11 @@ data _null_; /* if number of EXECs and CLEANs differs but both are positive issue a Warning */ if (0 < e < c) or (0 < c < e) or not(EXEC.NUM_ITEMS = CLEAN.NUM_ITEMS = F.NUM_ITEMS) then do; - put "WARNING: Number of EXEC type and CLEAN type files differs!" / - "WARNING- Each EXEC file should have CLEAN file counterpart and vice versa." / - 'WARNING- Please create appropriate files and make your package a "role model".' / - 'WARNING- ' / - 'WARNING- The list of differences:'; + put "WARNING: Number of EXEC type and CLEAN type files differs!" + / "WARNING- Each EXEC file should have CLEAN file counterpart and vice versa." + / 'WARNING- Please create appropriate files and make your package a "role model".' + / 'WARNING- ' + / 'WARNING- The list of differences:'; do while(IF.next()=0); ne = 0; nc = 0; @@ -787,10 +837,10 @@ data _null_; /* if EXECs are positive but CLEANs are zero (or other way around) issue an Error */ if (0 = e < c) or (0 = c < e) then do; - put "ERROR: There are " e "EXECs files and " c "CLEANs files!" / - "ERROR- Each EXEC file should have CLEAN file counterpart and vice versa." / - 'ERROR- Please create appropriate files and make your package a "role model".' / - 'ERROR: [&sysmacroname.] Aborting package generation!' ; + put "ERROR: There are " e "EXECs files and " c "CLEANs files!" + / "ERROR- Each EXEC file should have CLEAN file counterpart and vice versa." + / 'ERROR- Please create appropriate files and make your package a "role model".' + / 'ERROR: [&sysmacroname.] Aborting package generation!'; abort; end; end; @@ -877,6 +927,8 @@ run; proc contents data = &filesWithCodes.; run; */ +%local _titleNumber_; +%let _titleNumber_=6; title1 "Package location is: &filesLocation."; title2 "User: &SYSUSERID., Datetime: &packageGenerated., SAS version: &SYSVLONG4."; title3 "Package encoding: '&packageEncoding.', Session encoding: '&SYSENCODING.'."; @@ -887,14 +939,21 @@ title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_."; or (%superq(packageReqPackages) ne ) %then %do; - title7 "Required SAS licences: %qsysfunc(compress(%superq(packageRequired), %str(%'%")))" ; /* ' */ - title8 "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */ + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Required SAS licences: %qsysfunc(compress(%superq(packageRequired), %str(%'%")))" ; /* ' */ + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */ + %end; +%if %superq(buildLocation) NE %superq(filesLocation) %then + %do; + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Package ZIP file location is: &buildLocation."; %end; -footnote1 "SAS Packages Framework, version 20251221"; +footnote1 "SAS Packages Framework, version 20251231"; proc print - data = &filesWithCodes.(drop=base folderRef fileRef rc folderid _abort_ fileId additionalContent) + data = &filesWithCodes.(drop=base build folderRef fileRef rc folderid _abort_ fileId additionalContent) width=full ; run; @@ -959,27 +1018,27 @@ run; file &zipReferrence.(license.sas) encoding = &packageEncoding.; length packageAuthor $ 1024; packageAuthor = symget('packageAuthor'); - put " "; - put "Copyright (c) since %sysfunc(today(),year4.) " packageAuthor ; - put " "; - put "Permission is hereby granted, free of charge, to any person obtaining a copy"; - put 'of this software and associated documentation files (the "Software"), to deal'; - put "in the Software without restriction, including without limitation the rights"; - put "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"; - put "copies of the Software, and to permit persons to whom the Software is"; - put "furnished to do so, subject to the following conditions:"; - put " "; - put "The above copyright notice and this permission notice shall be included"; - put "in all copies or substantial portions of the Software."; - put " "; - put 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR'; - put "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"; - put "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"; - put "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"; - put "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"; - put "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"; - put "SOFTWARE."; - put " "; + put " " + / "Copyright (c) since %sysfunc(today(),year4.) " packageAuthor + / " " + / "Permission is hereby granted, free of charge, to any person obtaining a copy" + / 'of this software and associated documentation files (the "Software"), to deal' + / "in the Software without restriction, including without limitation the rights" + / "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" + / "copies of the Software, and to permit persons to whom the Software is" + / "furnished to do so, subject to the following conditions:" + / " " + / "The above copyright notice and this permission notice shall be included" + / "in all copies or substantial portions of the Software." + / " " + / 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR' + / "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," + / "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" + / "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" + / "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," + / "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" + / "SOFTWARE." + / " "; run; %end; @@ -1009,16 +1068,16 @@ data _null_; packageLicense = quote(strip(symget('packageLicense')),'"'); packageGenerated = quote(strip(symget('packageGenerated')),'"'); - put ' data _null_; '; /* simple "%local" returns error while loading package */ - put ' call symputX("packageName", ' packageName ', "L");'; - put ' call symputX("packageVersion", ' packageVersion ', "L");'; - put ' call symputX("packageTitle", ' packageTitle ', "L");'; - put ' call symputX("packageAuthor", ' packageAuthor ', "L");'; - put ' call symputX("packageMaintainer", ' packageMaintainer ', "L");'; - put ' call symputX("packageEncoding", ' packageEncoding ', "L");'; - put ' call symputX("packageLicense", ' packageLicense ', "L");'; - put ' call symputX("packageGenerated", ' packageGenerated ', "L");'; - put ' run; '; + put ' data _null_; ' /* simple "%local" returns error while loading package */ + / ' call symputX("packageName", ' packageName ', "L");' + / ' call symputX("packageVersion", ' packageVersion ', "L");' + / ' call symputX("packageTitle", ' packageTitle ', "L");' + / ' call symputX("packageAuthor", ' packageAuthor ', "L");' + / ' call symputX("packageMaintainer", ' packageMaintainer ', "L");' + / ' call symputX("packageEncoding", ' packageEncoding ', "L");' + / ' call symputX("packageLicense", ' packageLicense ', "L");' + / ' call symputX("packageGenerated", ' packageGenerated ', "L");' + / ' run; '; stop; run; @@ -1043,82 +1102,76 @@ run; %put NOTE-; data _null_; file &zipReferrence.(iceloadpackage.sas) encoding = &packageEncoding.; - put " "; - put ' /* Temporary replacement of loadPackage() macro. */ '; - put ' %macro ICEloadPackage( '; - put ' packageName /* name of a package */ '; - put ' , path = %sysfunc(pathname(packages)) /* location of a package */ '; - put ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ '; - put ' , zip = zip /* file ext. */ '; - put ' , requiredVersion = . /* required version */ '; - put ' , source2 = /* source2 */ '; - put ' , suppressExec = 0 /* suppress execs */ '; - put ' )/secure; '; - put ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; '; - put ' %local _PackageFileref_; '; - put ' data _null_; '; - put ' call symputX("_PackageFileref_", "P" !! put(MD5(lowcase("&packageName.")), hex7. -L), "L"); '; - put ' run; '; + put " " + / ' /* Temporary replacement of loadPackage() macro. */ ' + / ' %macro ICEloadPackage( ' + / ' packageName /* name of a package */ ' + / ' , path = %sysfunc(pathname(packages)) /* location of a package */ ' + / ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ ' + / ' , zip = zip /* file ext. */ ' + / ' , requiredVersion = . /* required version */ ' + / ' , source2 = /* source2 */ ' + / ' , suppressExec = 0 /* suppress execs */ ' + / ' )/secure; ' + / ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; ' + / ' %local _PackageFileref_; ' + / ' data _null_; ' + / ' call symputX("_PackageFileref_", "P" !! put(MD5(lowcase("&packageName.")), hex7. -L), "L"); ' + / ' run; ' - put ' filename &_PackageFileref_. &ZIP. '; - put ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) '; - put ' ; '; - put ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; '; - put ' filename &_PackageFileref_. clear; '; + / ' filename &_PackageFileref_. &ZIP. ' + / ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) ' + / ' ; ' + / ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; ' + / ' filename &_PackageFileref_. clear; ' /* test if required version of package is "good enough" */ - put ' %local rV pV rV0 pV0 rVsign; '; - put ' %let pV0 = %sysfunc(compress(&packageVersion.,.,kd)); '; - put ' %let pV = %sysevalf((%scan(&pV0.,1,.,M)+0)*1e8 '; - put ' + (%scan(&pV0.,2,.,M)+0)*1e4 '; - put ' + (%scan(&pV0.,3,.,M)+0)*1e0); '; - put ' '; - put ' %let rV0 = %sysfunc(compress(&requiredVersion.,.,kd)); '; - put ' %let rVsign = %sysfunc(compress(&requiredVersion.,<=>,k)); '; - put ' %if %superq(rVsign)= %then %let rVsign=<=; '; - put ' %else %if NOT (%superq(rVsign) IN (%str(=) %str(<=) %str(=<) %str(=>) %str(>=) %str(<) %str(>))) %then '; - put ' %do; '; - put ' %put WARNING: Illegal operatopr "%superq(rVsign)"! Default(<=) will be used.; '; - put ' %put WARNING- Supported operators are: %str(= <= =< => >= < >); '; - put ' %let rVsign=<=; '; - put ' %end; '; - put ' %let rV = %sysevalf((%scan(&rV0.,1,.,M)+0)*1e8 '; - put ' + (%scan(&rV0.,2,.,M)+0)*1e4 '; - put ' + (%scan(&rV0.,3,.,M)+0)*1e0); '; - put ' '; - put ' %if NOT %sysevalf(&rV. &rVsign. &pV.) %then '; - put ' %do; '; - put ' %put ERROR: Package &packageName. will not be loaded!; '; - put ' %put ERROR- Required version is &rV0.; '; - put ' %put ERROR- Provided version is &pV0.; '; - put ' %put ERROR- Condition %bquote((&rV0. &rVsign. &pV0.)) evaluates to %sysevalf(&rV. &rVsign. &pV.); '; - put ' %put ERROR- Verify installed version of the package.; '; - put ' %put ERROR- ; '; - put ' %GOTO WrongVersionOFPackage; /*%RETURN;*/ '; - put ' %end; '; - - put ' filename &_PackageFileref_. &ZIP. '; - put ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) '; - put ' ENCODING = '; - put ' %if %bquote(&packageEncoding.) NE %then &packageEncoding. ; '; - put ' %else utf8 ; '; - put ' ; '; - - put ' %local cherryPick; %let cherryPick=*; '; - put ' %local tempLoad_minoperator; '; - put ' %let tempLoad_minoperator = %sysfunc(getoption(minoperator)); '; - put ' options minoperator; '; - - put ' %if %superq(suppressExec) NE 1 %then %let suppressExec = 0; '; - - put ' %include &_PackageFileref_.(load.sas) / &source2.; '; - put ' options &tempLoad_minoperator.; '; - - put ' filename &_PackageFileref_. clear; '; - put ' %WrongVersionOFPackage: '; - - put ' %mend ICEloadPackage; '; - put " "; + / ' %local rV pV rV0 pV0 rVsign; ' + / ' %let pV0 = %sysfunc(compress(&packageVersion.,.,kd)); ' + / ' %let pV = %sysevalf((%scan(&pV0.,1,.,M)+0)*1e8 ' + / ' + (%scan(&pV0.,2,.,M)+0)*1e4 ' + / ' + (%scan(&pV0.,3,.,M)+0)*1e0); ' + / ' ' + / ' %let rV0 = %sysfunc(compress(&requiredVersion.,.,kd)); ' + / ' %let rVsign = %sysfunc(compress(&requiredVersion.,<=>,k)); ' + / ' %if %superq(rVsign)= %then %let rVsign=<=; ' + / ' %else %if NOT (%superq(rVsign) IN (%str(=) %str(<=) %str(=<) %str(=>) %str(>=) %str(<) %str(>))) %then ' + / ' %do; ' + / ' %put WARNING: Illegal operatopr "%superq(rVsign)"! Default(<=) will be used.; ' + / ' %put WARNING- Supported operators are: %str(= <= =< => >= < >); ' + / ' %let rVsign=<=; ' + / ' %end; ' + / ' %let rV = %sysevalf((%scan(&rV0.,1,.,M)+0)*1e8 ' + / ' + (%scan(&rV0.,2,.,M)+0)*1e4 ' + / ' + (%scan(&rV0.,3,.,M)+0)*1e0); ' + / ' ' + / ' %if NOT %sysevalf(&rV. &rVsign. &pV.) %then ' + / ' %do; ' + / ' %put ERROR: Package &packageName. will not be loaded!; ' + / ' %put ERROR- Required version is &rV0.; ' + / ' %put ERROR- Provided version is &pV0.; ' + / ' %put ERROR- Condition %bquote((&rV0. &rVsign. &pV0.)) evaluates to %sysevalf(&rV. &rVsign. &pV.); ' + / ' %put ERROR- Verify installed version of the package.; ' + / ' %put ERROR- ; ' + / ' %GOTO WrongVersionOFPackage; /*%RETURN;*/ ' + / ' %end; ' + / ' filename &_PackageFileref_. &ZIP. ' + / ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) ' + / ' ENCODING = ' + / ' %if %superq(packageEncoding) NE %then &packageEncoding. ; ' + / ' %else utf8 ; ' + / ' ; ' + / ' %local cherryPick; %let cherryPick=*; ' + / ' %local tempLoad_minoperator; ' + / ' %let tempLoad_minoperator = %sysfunc(getoption(minoperator)); ' + / " " + / ' %if %superq(suppressExec) NE 1 %then %let suppressExec = 0; ' + / ' %include &_PackageFileref_.(load.sas) / &source2.; ' + / ' options &tempLoad_minoperator.; ' + / ' filename &_PackageFileref_. clear; ' + / ' %WrongVersionOFPackage: ' + / ' %mend ICEloadPackage; ' + / " "; run; /* loading package files */ @@ -1126,6 +1179,7 @@ run; %put NOTE: Preparing load file.; %put NOTE- ^^^^^^^^^^^^^^^^^^^^; %put NOTE-; + data _null_; if NOBS = 0 then stop; @@ -1146,11 +1200,11 @@ data _null_; put 'data _null_; '; put ' if NOT ("*"=symget("cherryPick")) then do; '; /* Cherry Pick test0 start */ - put ' put "NOTE- "; ' / - ' put "NOTE: *** Cherry Picking ***"; ' / - ' put "NOTE- Cherry Picking in action!! Be advised that"; ' / - ' put "NOTE- dependencies/required packages will not be loaded!"; ' / - ' put "NOTE- "; ' ; + put ' put "NOTE- "; ' + / ' put "NOTE: *** Cherry Picking ***"; ' + / ' put "NOTE- Cherry Picking in action!! Be advised that"; ' + / ' put "NOTE- dependencies/required packages will not be loaded!"; ' + / ' put "NOTE- "; '; put ' end; ' ; /* Cherry Pick test0 end */ put 'run; '; @@ -1169,72 +1223,72 @@ data _null_; or (%superq(packageReqPackages) ne ) %then %do; - put ' data _null_; '; - put ' call symputX("packageRequiredErrors", 0, "L"); '; - put ' run; '; + put ' data _null_; ' + / ' call symputX("packageRequiredErrors", 0, "L"); ' + / ' run; '; %end; %if %superq(packageRequired) ne %then %do; - put ' %put NOTE- *Testing required SAS components*%sysfunc(DoSubL( '; /* <- DoSubL() is here */ - put ' options nonotes nosource %str(;) '; - put ' options ls=max ps=max locale=en_US %str(;) '; - put ' /* temporary redirect log */ '; - put ' filename _stinit_ TEMP %str(;) '; - put ' proc printto log = _stinit_ %str(;) run %str(;) '; - put ' /* print out setinit */ '; - put ' proc setinit %str(;) run %str(;) '; - put ' proc printto %str(;) run %str(;) '; + put ' %put NOTE- *Testing required SAS components*%sysfunc(DoSubL(' /* <- DoSubL() is here */ + / ' options nonotes nosource %str(;) ' + / ' options ls=max ps=max locale=en_US %str(;) ' + / ' /* temporary redirect log */ ' + / ' filename _stinit_ TEMP %str(;) ' + / ' proc printto log = _stinit_ %str(;) run %str(;) ' + / ' /* print out setinit */ ' + / ' proc setinit %str(;) run %str(;) ' + / ' proc printto %str(;) run %str(;) ' - put ' data _null_ %str(;) '; - put ' /* loadup checklist of required SAS components */ '; - put ' if _n_ = 1 then '; - put ' do %str(;) '; - put ' length req $ 256 %str(;) '; - put ' declare hash R() %str(;) '; - put ' _N_ = R.defineKey("req") %str(;) '; - put ' _N_ = R.defineDone() %str(;) '; - put ' declare hiter iR("R") %str(;) '; + / ' data _null_ %str(;) ' + / ' /* loadup checklist of required SAS components */ ' + / ' if _n_ = 1 then ' + / ' do %str(;) ' + / ' length req $ 256 %str(;) ' + / ' declare hash R() %str(;) ' + / ' _N_ = R.defineKey("req") %str(;) ' + / ' _N_ = R.defineDone() %str(;) ' + / ' declare hiter iR("R") %str(;) '; length packageRequired $ 32767; packageRequired = upcase(symget('packageRequired')); - put ' do req = %bquote(' / packageRequired / ') %str(;) '; - put ' _N_ = R.add(key:req,data:req) %str(;) '; - put ' end %str(;) '; - put ' end %str(;) '; - put ' '; - put ' /* read in output from proc setinit */ '; - put ' infile _stinit_ end=eof %str(;) '; - put ' input %str(;) '; - /*put ' put "*> " _infile_ %str(;) '; */ /* for testing */ - put ' '; - put ' /* if component is in setinit remove it from checklist */ '; - put ' if _infile_ =: "---" then '; - put ' do %str(;) '; - put ' req = upcase(substr(_infile_, 4, 64)) %str(;) '; - put ' if R.find(key:req) = 0 then '; - put ' do %str(;) '; - put ' _N_ = R.remove() %str(;) '; - put ' end %str(;) '; - put ' end %str(;) '; - put ' '; - put ' /* if checklist is not null rise error */ '; - put ' if eof and R.num_items > 0 then '; - put ' do %str(;) '; - put ' put "WARNING- ###########################################" %str(;) '; - put ' put "WARNING: The following SAS components are missing! " %str(;) '; - put ' call symputX("packageRequiredErrors", 0, "L") %str(;) '; - put ' do while(iR.next() = 0) %str(;) '; - put ' put "WARNING- " req %str(;) '; - put ' end %str(;) '; - put ' put "WARNING: The package may NOT WORK as expected " %str(;) '; - put ' put "WARNING: or even result with ERRORS! " %str(;) '; - put ' put "WARNING- ###########################################" %str(;) '; - put ' put %str(;) '; - put ' end %str(;) '; - put ' run %str(;) '; - put ' filename _stinit_ clear %str(;) '; - put ' options notes source %str(;) '; - put ' ))*; '; + put ' do req = %bquote(' / packageRequired / ') %str(;) ' + / ' _N_ = R.add(key:req,data:req) %str(;) ' + / ' end %str(;) ' + / ' end %str(;) ' + / ' ' + / ' /* read in output from proc setinit */ ' + / ' infile _stinit_ end=eof %str(;) ' + / ' input %str(;) ' + /* / ' put "*> " _infile_ %str(;) ' */ /* for testing */ + / ' ' + / ' /* if component is in setinit remove it from checklist */ ' + / ' if _infile_ =: "---" then ' + / ' do %str(;) ' + / ' req = upcase(substr(_infile_, 4, 64)) %str(;) ' + / ' if R.find(key:req) = 0 then ' + / ' do %str(;) ' + / ' _N_ = R.remove() %str(;) ' + / ' end %str(;) ' + / ' end %str(;) ' + / ' ' + / ' /* if checklist is not null rise error */ ' + / ' if eof and R.num_items > 0 then ' + / ' do %str(;) ' + / ' put "WARNING- ###########################################" %str(;) ' + / ' put "WARNING: The following SAS components are missing! " %str(;) ' + / ' call symputX("packageRequiredErrors", 0, "L") %str(;) ' + / ' do while(iR.next() = 0) %str(;) ' + / ' put "WARNING- " req %str(;) ' + / ' end %str(;) ' + / ' put "WARNING: The package may NOT WORK as expected " %str(;) ' + / ' put "WARNING: or even result with ERRORS! " %str(;) ' + / ' put "WARNING- ###########################################" %str(;) ' + / ' put %str(;) ' + / ' end %str(;) ' + / ' run %str(;) ' + / ' filename _stinit_ clear %str(;) ' + / ' options notes source %str(;) ' + / ' ))*; '; %end; %if %superq(packageReqPackages) ne %then @@ -1244,146 +1298,145 @@ data _null_; packageReqPackages = lowcase(symget('packageReqPackages')); /* try to load required packages */ - put 'data _null_ ; '; - put ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages loading."; stop; end; '; - put ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' end; '; - put ' SYSloadedPackages = lowcase(SYSloadedPackages); '; + put 'data _null_ ; ' + / ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages loading."; stop; end; ' + / ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' end; ' + / ' SYSloadedPackages = lowcase(SYSloadedPackages); ' - put ' declare hash LP(); '; - put ' LP.defineKey("name"); '; - put ' LP.defineData("vers"); '; - put ' LP.defineDone(); '; - put ' do _N_ = 1 to countw(SYSloadedPackages); '; - put ' req = kscanx(SYSloadedPackages, _N_, " "); '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' _RC_ = LP.add(); '; - put ' end; '; + / ' declare hash LP(); ' + / ' LP.defineKey("name"); ' + / ' LP.defineData("vers"); ' + / ' LP.defineDone(); ' + / ' do _N_ = 1 to countw(SYSloadedPackages); ' + / ' req = kscanx(SYSloadedPackages, _N_, " "); ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' _RC_ = LP.add(); ' + / ' end; ' /* check if elements of the framework are available */ - put ' LoadPackageExist = input(resolve(''%SYSMACEXIST( loadPackage)''), best.); '; - put ' ICELoadPackageExist = input(resolve(''%SYSMACEXIST(ICEloadPackage)''), best.); '; + / ' LoadPackageExist = input(resolve(''%SYSMACEXIST( loadPackage)''), best.); ' + / ' ICELoadPackageExist = input(resolve(''%SYSMACEXIST(ICEloadPackage)''), best.); ' - put ' do req = ' / packageReqPackages / ' ; '; -/* put ' req = compress(req, "(.)", "KDF"); ';*/ - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = ""; '; - put ' LP_find = LP.find(); '; + / ' do req = ' / packageReqPackages / ' ; ' +/* / ' req = compress(req, "(.)", "KDF"); '*/ + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = ""; ' + / ' LP_find = LP.find(); ' /* convert major.minor.patch to number*/ - put ' array V verR vers ; '; - put ' array VN verRN versN; '; - put ' do over V; '; - put ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 '; - put ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 '; - put ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; '; - put ' end; '; + / ' array V verR vers ; ' + / ' array VN verRN versN; ' + / ' do over V; ' + / ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 ' + / ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 ' + / ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; ' + / ' end; ' - put ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then '; - put ' do; '; - put ' put "NOTE: Trying to load required SAS package: " req; '; - put ' if LoadPackageExist then '; - put ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); '; - put ' else if ICELoadPackageExist then '; - put ' call execute(cats(''%nrstr(%ICEloadPackage('', name, ", requiredVersion = ", verR, "))")); '; - put ' end ; '; - put ' end ; '; - put ' stop; '; - put 'run; '; + / ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then ' + / ' do; ' + / ' put "NOTE: Trying to load required SAS package: " req; ' + / ' if LoadPackageExist then ' + / ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); ' + / ' else if ICELoadPackageExist then ' + / ' call execute(cats(''%nrstr(%ICEloadPackage('', name, ", requiredVersion = ", verR, "))")); ' + / ' end ; ' + / ' end ; ' + / ' stop; ' + / 'run; ' /* test if required packages are loaded */ - put 'data _null_ ; '; - put ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages checking."; stop; end; '; - put ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = lowcase(SYSloadedPackages); '; + / 'data _null_ ; ' + / ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages checking."; stop; end; ' + / ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = lowcase(SYSloadedPackages); ' - put ' declare hash LP(); '; - put ' LP.defineKey("name"); '; - put ' LP.defineData("vers"); '; - put ' LP.defineDone(); '; - put ' do _N_ = 1 to countw(SYSloadedPackages); '; - put ' req = kscanx(SYSloadedPackages, _N_, " "); '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' _RC_ = LP.add(); '; - put ' end; '; + / ' declare hash LP(); ' + / ' LP.defineKey("name"); ' + / ' LP.defineData("vers"); ' + / ' LP.defineDone(); ' + / ' do _N_ = 1 to countw(SYSloadedPackages); ' + / ' req = kscanx(SYSloadedPackages, _N_, " "); ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' _RC_ = LP.add(); ' + / ' end; ' - put ' missingPackagr = 0; '; - put ' do req = ' / packageReqPackages / ' ; '; -/* put ' req = compress(req, "(.)", "KDF"); ';*/ - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = " "; '; - put ' LP_find = LP.find(); '; + / ' missingPackagr = 0; ' + / ' do req = ' / packageReqPackages / ' ; ' +/* / ' req = compress(req, "(.)", "KDF"); '*/ + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = " "; ' + / ' LP_find = LP.find(); ' /* convert major.minor.patch to number*/ - put ' array V verR vers ; '; - put ' array VN verRN versN; '; - put ' do over V; '; - put ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 '; - put ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 '; - put ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; '; - put ' end; '; - - put ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then '; - put ' do; '; - put ' missingPackagr = 1; '; - put ' put "ERROR: SAS package: " req "is missing! Download it by hand or if the SAS session";'; - put ' put "ERROR- has access to the Internet and the package is available at SASPAC repository";'; - put ' put ''ERROR- use %installPackage('' name +(-1) "(" verR +(-1) ")) to install it."/; '; - put ' put ''ERROR- Use %loadPackage('' name +(-1) ", requiredVersion=" verR +(-1) ") to load it."/;'; - put ' end ; '; - put ' end ; '; - put ' if missingPackagr then call symputX("packageRequiredErrors", 1, "L"); '; - put ' end; '; - put ' else '; - put ' do; '; - put ' put "ERROR: No package loaded!"; '; - put ' call symputX("packageRequiredErrors", 1, "L"); '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' put "ERROR: SAS package " req "is missing! Download it by hand or if the SAS session";'; - put ' put "ERROR- has access to the Internet and the package is available at SASPAC repository";'; - put ' put ''ERROR- use %installPackage('' name +(-1) "(" vers +(-1) ")) to install it."/; '; - put ' put ''ERROR- Use %loadPackage('' name +(-1)", requiredVersion=" vers +(-1) ") to load it."/;'; - put ' end ; '; - put ' end; '; - put ' stop; '; - put 'run; '; + / ' array V verR vers ; ' + / ' array VN verRN versN; ' + / ' do over V; ' + / ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 ' + / ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 ' + / ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; ' + / ' end; ' + / ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then ' + / ' do; ' + / ' missingPackagr = 1; ' + / ' put "ERROR: SAS package: " req "is missing! Download it by hand or if the SAS session"; ' + / ' put "ERROR- has access to the Internet and the package is available at SASPAC repository"; ' + / ' put ''ERROR- use %installPackage('' name +(-1) "(" verR +(-1) ")) to install it."/; ' + / ' put ''ERROR- Use %loadPackage('' name +(-1) ", requiredVersion=" verR +(-1) ") to load it."/; ' + / ' end ; ' + / ' end ; ' + / ' if missingPackagr then call symputX("packageRequiredErrors", 1, "L"); ' + / ' end; ' + / ' else ' + / ' do; ' + / ' put "ERROR: No package loaded!"; ' + / ' call symputX("packageRequiredErrors", 1, "L"); ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' put "ERROR: SAS package " req "is missing! Download it by hand or if the SAS session"; ' + / ' put "ERROR- has access to the Internet and the package is available at SASPAC repository"; ' + / ' put ''ERROR- use %installPackage('' name +(-1) "(" vers +(-1) ")) to install it."/; ' + / ' put ''ERROR- Use %loadPackage('' name +(-1)", requiredVersion=" vers +(-1) ") to load it."/; ' + / ' end ; ' + / ' end; ' + / ' stop; ' + / 'run; '; %end; %if (%superq(packageRequired) ne ) or (%superq(packageReqPackages) ne ) %then %do; - put ' data _null_; '; - put ' if 1 = symgetn("packageRequiredErrors") then '; - put ' do; '; - put ' put "ERROR: Loading package &packageName. will be aborted!";'; - put ' put "ERROR- Required components are missing."; '; - put ' put "ERROR- *** STOP ***"; '; - put ' call symputX("packageRequiredErrors",'; - put ' ''options ls = &ls_tmp. ps = &ps_tmp. '; - put ' ¬es_tmp. &source_tmp. msglevel=&msglevel_tmp. '; - put ' &stimer_tmp. &fullstimer_tmp. ;'; - put ' data _null_;abort;run;'', "L"); '; - put ' end; '; - put ' else '; - put ' call symputX("packageRequiredErrors", " ", "L");'; - put ' run; '; - put ' &packageRequiredErrors. '; + put ' data _null_; ' + / ' if 1 = symgetn("packageRequiredErrors") then ' + / ' do; ' + / ' put "ERROR: Loading package &packageName. will be aborted!";' + / ' put "ERROR- Required components are missing."; ' + / ' put "ERROR- *** STOP ***"; ' + / ' call symputX("packageRequiredErrors",' + / ' ''options ls = &ls_tmp. ps = &ps_tmp. ' + / ' ¬es_tmp. &source_tmp. msglevel=&msglevel_tmp. ' + / ' &stimer_tmp. &fullstimer_tmp. ;' + / ' data _null_;abort;run;'', "L"); ' + / ' end; ' + / ' else ' + / ' call symputX("packageRequiredErrors", " ", "L");' + / ' run; ' + / ' &packageRequiredErrors. '; %end; @@ -1422,9 +1475,9 @@ data _null_; if 1 = isFunction and upcase(type)=:'FUNCTION' then do; /* macro variable for test if cherry picking used FCMP */ - put 'data _null_; '; - put " call symputX('cherryPick_FCMP', exist('work.&packageName.fcmp'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_FCMP', exist('work.&packageName.fcmp'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='FUNCTIONS' then do; @@ -1434,9 +1487,9 @@ data _null_; if 1 = isProto and upcase(type)='PROTO' then do; /* macro variable for test if cherry picking used PROTO */ - put 'data _null_; '; - put " call symputX('cherryPick_PROTO', exist('work.&packageName.proto'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_PROTO', exist('work.&packageName.proto'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='PROTO' then do; @@ -1445,15 +1498,15 @@ data _null_; value of "package=" overwrites previously created content */ /* header for multiple functions in one PROTO run */ - put "proc proto package = work.&packageName.proto.package" ProtoGrpNum / - " LABEL='Proc Proto C functions for &packageName. package, part" ProtoGrpNum "' ; "; + put "proc proto package = work.&packageName.proto.package" ProtoGrpNum + / " LABEL='Proc Proto C functions for &packageName. package, part" ProtoGrpNum "' ; "; end; if 1 = isFormat and upcase(type)=:'FORMAT' then do; /* macro variable for test if cherry picking used FORMAT */ - put 'data _null_; '; - put " call symputX('cherryPick_FORMAT', cexist('work.&packageName.format'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_FORMAT', cexist('work.&packageName.format'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='FORMATS' then do; @@ -1463,25 +1516,25 @@ data _null_; if 1 = isIMLmodule and upcase(type)='IMLMODULE' then do; /* macro variable for test if cherry picking used IML */ - put 'data _null_; '; - put ' call symputX("cherryPick_IML_ALL", 0, "L"); '; - put 'run; '; + put 'data _null_; ' + / ' call symputX("cherryPick_IML_ALL", 0, "L"); ' + / 'run; '; end; if 1 = FIRST.type and upcase(type)='IMLMODULE' then do; /* macro variable for test if cherry picking used IML */ - put 'data _null_; '; - put ' call symputX("cherryPick_IML", 0, "L"); '; - put 'run; '; + put 'data _null_; ' + / ' call symputX("cherryPick_IML", 0, "L"); ' + / 'run; '; /* header, for IML modules */ put "proc iml ; "; end; /* HEADERS for PROC IML, FCMP, and PROTO - end */ - put ' ' / - '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; '; /* Cherry Pick test1 start */ - put ' %put NOTE- ;'; - put ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; + put ' ' + / '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; ' /* Cherry Pick test1 start */ + / ' %put NOTE- ;' + / ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; if upcase(type)=:'MACRO' then put ' %put %sysfunc(ifc(%SYSMACEXIST(' fileshort +(-1) ')=1, NOTE# Macro ' fileshort @@ -1517,16 +1570,16 @@ data _null_; if 1 = isDS2pck and upcase(type)=:'DS2PCK' then do; /* macro variable for test if cherry picking used DS2 package */ - put 'data _null_; '; - put " call symputX('cherryPick_DS2PCK', 0, 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_DS2PCK', 0, 'L'); " + / 'run; '; end; if 1 = isDS2thr and upcase(type)=:'DS2THR' then do; /* macro variable for test if cherry picking used DS2 threads */ - put 'data _null_; '; - put " call symputX('cherryPick_DS2THR', 0, 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_DS2THR', 0, 'L'); " + / 'run; '; end; @@ -1620,12 +1673,12 @@ data _null_; end; if 1 = LAST.type and upcase(type)='IMLMODULE' then /* footer, for IML modules */ do; - put '%if 0 < &cherryPick_IML. %then %do; ' / - '%let cherryPick_IML_ALL = %eval(&cherryPick_IML_ALL. + &cherryPick_IML.);' / - "reset storage = WORK.&packageName.IML; " / /* set the storage location for modules */ - "store module = _ALL_; " / /* and store all created modules */ - '%end; ' / - "quit; " / ; + put '%if 0 < &cherryPick_IML. %then %do; ' + / '%let cherryPick_IML_ALL = %eval(&cherryPick_IML_ALL. + &cherryPick_IML.);' + / "reset storage = WORK.&packageName.IML; " /* set the storage location for modules */ + / "store module = _ALL_; " /* and store all created modules */ + / '%end; ' + / "quit; " ; end; /* FOOTERS for PROC IML, FCMP, and PROTO - end */ @@ -1636,11 +1689,11 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'FUNCTION') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' / - " ,work.%sysfunc(lowcase(&packageName.fcmp)),""'( )'"",RIO))" / - ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.fcmp)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' + / " ,work.%sysfunc(lowcase(&packageName.fcmp)),""'( )'"",RIO))" + / ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.fcmp)));)" + / '))' ; end; /* add the link to the proto functions dataset, only for the first occurrence */ @@ -1650,11 +1703,11 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'PROTO') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' / - " ,work.%sysfunc(lowcase(&packageName.proto)),""'( )'"",RIO))" / - ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.proto)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' + / " ,work.%sysfunc(lowcase(&packageName.proto)),""'( )'"",RIO))" + / ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.proto)));)" + / '))' ; end; /* add the link to the formats catalog, only for the first occurrence */ @@ -1664,76 +1717,76 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'FORMAT') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(fmtsearch)))' / - " ,work.%sysfunc(lowcase(&packageName.format)),""'( )'"",RIO))" / - ',,%str(options' " INSERT=(fmtsearch = work.%sysfunc(lowcase(&packageName.format)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(fmtsearch)))' + / " ,work.%sysfunc(lowcase(&packageName.format)),""'( )'"",RIO))" + / ',,%str(options' " INSERT=(fmtsearch = work.%sysfunc(lowcase(&packageName.format)));)" + / '))'; end; end; /* loopOverTypes - start */ /* this is a header for CASLudf macro */ - put 'data _null_; '; - put ' call symputX("cherryPick_CASLUDF", 0, "L"); '; - put 'run; '; - put 'data _null_;'; - put 'length CASLUDF $ 32767;'; - put 'dtCASLudf = datetime();'; - put 'CASLUDF = '; - put ' ''%macro ' "&packageName.CASLudf(' "; - put ' !! "list=1,depList=" '; - %if %superq(packageReqPackages) ne %then - %do; - length reqPackage $ 32; - do i = 1 to countw(packageReqPackages, ",", "Q"); - reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; - put ' !! " ' reqPackage ' " '; - end; - %end; + put 'data _null_; ' + / ' call symputX("cherryPick_CASLUDF", 0, "L"); ' + / 'run; ' + / 'data _null_; ' + / 'length CASLUDF $ 32767; ' + / 'dtCASLudf = datetime(); ' + / 'CASLUDF = ' + / ' ''%macro ' "&packageName.CASLudf(' " + / ' !! "list=1,depList=" '; + + %if %superq(packageReqPackages) ne %then + %do; + length reqPackage $ 32; + do i = 1 to countw(packageReqPackages, ",", "Q"); + reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; + put ' !! " ' reqPackage ' " '; + end; + %end; put " !! ')/ des = ''CASL User Defined Functions loader for &packageName. package'';'"; - put ' !! '' %if HELP = %superq(list) %then ''' / - ' !! '' %do; ''' / - ' !! '' %put ****************************************************************************;''' / - ' !! '' %put This is help for the `' "&packageName.CASLudf" '` macro;''' / - ' !! '' %put Parameters (optional) are the following:;''' / + put ' !! '' %if HELP = %superq(list) %then ''' + / ' !! '' %do; ''' + / ' !! '' %put ****************************************************************************;''' + / ' !! '' %put This is help for the `' "&packageName.CASLudf" '` macro;''' + / ' !! '' %put Parameters (optional) are the following:;''' - ' !! '' %put - `list` indicates if the list of loaded CASL UDFs should be displayed,;''' / - ' !! '' %put %str( )when set to the value of `1` (the default) runs `FUNCTIONLIST USER%str(;)`,;''' / - ' !! '' %put %str( )when set to the value of `HELP` (upcase letters!) displays this help message.;''' / + / ' !! '' %put - `list` indicates if the list of loaded CASL UDFs should be displayed,;''' + / ' !! '' %put %str( )when set to the value of `1` (the default) runs `FUNCTIONLIST USER%str(;)`,;''' + / ' !! '' %put %str( )when set to the value of `HELP` (upcase letters!) displays this help message.;''' - ' !! '' %put - `depList` [technical] contains the list of dependencies required by the package.;''' / - ' !! '' %put %str( )for _this_ instance of the macro the default value is: `' @; - %if %superq(packageReqPackages) ne %then - %do; - do i = 1 to countw(packageReqPackages, ",", "Q"); - reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; - put reqPackage @; - end; - %end; - put +(-1) '`.;''' / - ' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' / - ' !! '' %put with the SAS Packages Framework version 20251221.;''' / - ' !! '' %put ****************************************************************************;''' / - ' !! '' %GOTO theEndOfTheMacro;''' / - ' !! '' %end;''' ; + / ' !! '' %put - `depList` [technical] contains the list of dependencies required by the package.;''' + / ' !! '' %put %str( )for _this_ instance of the macro the default value is: `' @; + %if %superq(packageReqPackages) ne %then + %do; + do i = 1 to countw(packageReqPackages, ",", "Q"); + reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; + put reqPackage @; + end; + %end; + put +(-1) '`.;''' + / ' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' + / ' !! '' %put with the SAS Packages Framework version 20251231.;''' + / ' !! '' %put ****************************************************************************;''' + / ' !! '' %GOTO theEndOfTheMacro;''' + / ' !! '' %end;''' ; + put ' !! '' %if %superq(depList) ne %then ''' + / ' !! '' %do; ''' + / ' !! '' %do i = 1 %to %sysfunc(countw(&depList.,%str( ))); ''' + / ' !! '' %let depListNm = %scan(&depList.,&i.,%str( )); ''' + / ' !! '' %if %SYSMACEXIST(&depListNm.CASLudf) %then ''' + / ' !! '' %do; ''' + / ' !! '' %&depListNm.CASLudf(list=0) ''' + / ' !! '' %end; ''' + / ' !! '' %end; ''' + / ' !! '' %end; ''' - put ' !! '' %if %superq(depList) ne %then ''' / - ' !! '' %do; ''' / - ' !! '' %do i = 1 %to %sysfunc(countw(&depList.,%str( ))); ''' / - ' !! '' %let depListNm = %scan(&depList.,&i.,%str( )); ''' / - ' !! '' %if %SYSMACEXIST(&depListNm.CASLudf) %then ''' / - ' !! '' %do; ''' / - ' !! '' %&depListNm.CASLudf(list=0) ''' / - ' !! '' %end; ''' / - ' !! '' %end; ''' / - ' !! '' %end; ''' ; - - put ' !! '' %local tmp_NOTES;'' '; - put ' !! '' %let tmp_NOTES = %sysfunc(getoption(NOTES));'' '; + / ' !! '' %local tmp_NOTES;'' ' + / ' !! '' %let tmp_NOTES = %sysfunc(getoption(NOTES));''' ; /* the PATH macrovariable will be resolved when the load.sas file is executed */ put ' !! " filename ' "&_PackageFileref_." ' &ZIP. ''&path./' "%sysfunc(lowcase(&packageName.))" '.&zip.'';"'; @@ -1744,94 +1797,94 @@ data _null_; if not (upcase(type) = 'CASLUDF') then continue; /* only CASLUDF type in this loop */ isCASLudf + 1; - put ' ' / - '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; '; /* Cherry Pick test2 start */ - put ' %put NOTE- ;'; - put ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; + put ' ' + / '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; ' /* Cherry Pick test2 start */ + / ' %put NOTE- ;' + / ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;' /* for CASLUDF we are building code of a macro to be run while loading */ - put ' !! '' %include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;'''; - put ' %let cherryPick_CASLUDF = %eval(&cherryPick_CASLUDF. + 1);'; - put '%end; ' /; /* Cherry Pick test2 end */ + / ' !! '' %include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;''' + / ' %let cherryPick_CASLUDF = %eval(&cherryPick_CASLUDF. + 1);' + / '%end; ' / ; /* Cherry Pick test2 end */ end; /* loopOverTypes1 - end */ /* this is a footer for CASLudf macro */ - put ' !! " options nonotes;" ' / - " !! ' filename &_PackageFileref_. clear;' " / - ' !! '' options &tmp_NOTES.;'' ' / - ' !! '' %if 1 = %superq(list) %then '' ' / - ' !! '' %do; '' ' / - ' !! " FUNCTIONLIST USER;" ' / - ' !! " run;" ' / - ' !! '' %end; '' ' ; - put ' !! ''%theEndOfTheMacro: %mend;''; ' ; + put ' !! " options nonotes;" ' + / " !! ' filename &_PackageFileref_. clear;' " + / ' !! '' options &tmp_NOTES.;'' ' + / ' !! '' %if 1 = %superq(list) %then '' ' + / ' !! '' %do; '' ' + / ' !! " FUNCTIONLIST USER;" ' + / ' !! " run;" ' + / ' !! '' %end; '' ' + / ' !! ''%theEndOfTheMacro: %mend;''; ' ; /* generate macro for CASL user defined functions */ if 0 < isCASLudf then do; - put '%if 0 < &cherryPick_CASLUDF. %then %do; '; - /*put ' put / / CASLUDF / / ; ';*/ - put " rc = resolve(CASLUDF); "; - put ' put "NOTE: Macro named:"; '; - put " put @7 '%' '&packageName.CASLudf()'; "; - put ' put "NOTE- will be generated. Its purpose";'; - put ' put "NOTE- is to allow fast load of CASL"; '; - put ' put "NOTE- user defined functions into"; '; - put ' put "NOTE- the Proc CAS session."; '; - put ' put "NOTE-"; '; - put ' put "NOTE- Use it the following way:"; '; - put " put @7 'Proc CAS;'; "; - put " put @7 ' %' '&packageName.CASLudf()'; "; - put " put @7 ' <... your code ...>'; "; - put " put @7 'quit;'; "; - put ' put "NOTE-"; '; - put ' put "NOTE-To get help run:"; '; - put " put @7 ' %' '&packageName.CASLudf(list=HELP)';"; - put ' put "NOTE-"; '; - put '%end; '; + put '%if 0 < &cherryPick_CASLUDF. %then %do; ' + /* / ' put / / CASLUDF / / ; '*/ + / " rc = resolve(CASLUDF); " + / ' put "NOTE: Macro named:"; ' + / " put @7 '%' '&packageName.CASLudf()'; " + / ' put "NOTE- will be generated. Its purpose";' + / ' put "NOTE- is to allow fast load of CASL"; ' + / ' put "NOTE- user defined functions into"; ' + / ' put "NOTE- the Proc CAS session."; ' + / ' put "NOTE-"; ' + / ' put "NOTE- Use it the following way:"; ' + / " put @7 'Proc CAS;'; " + / " put @7 ' %' '&packageName.CASLudf()'; " + / " put @7 ' <... your code ...>'; " + / " put @7 'quit;'; " + / ' put "NOTE-"; ' + / ' put "NOTE-To get help run:"; ' + / " put @7 ' %' '&packageName.CASLudf(list=HELP)';" + / ' put "NOTE-"; ' + / '%end; '; end; put 'run;'/; /* cherry pick clean in cmplib for functions */ if isFunction then do; - put '%if 0 = &cherryPick_FCMP. %then %do;'; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%end;'; + put '%if 0 = &cherryPick_FCMP. %then %do;' + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%end;'; end; /* cherry pick clean in cmplib for proto */ if isProto then do; - put '%if 0 = &cherryPick_PROTO. %then %do;'; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; + put '%if 0 = &cherryPick_PROTO. %then %do;' + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));'; /* proc delete is adde because "empty" PROTO creates dataset too */ - put "proc delete data=work.&packageName.proto; run;"; - put '%end;'; + put "proc delete data=work.&packageName.proto; run;" + / '%end;'; end; /* list fmtsearch for formats */ if isFormat then do; - put '%if 0 = &cherryPick_FORMAT. %then %do;'; - put 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));'; - put 'options fmtsearch = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(fmtsearch))' / - ', %str(()) ))));'; - put '%end;'; - put '%put NOTE- ;'; + put '%if 0 = &cherryPick_FORMAT. %then %do;' + / 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));' + / 'options fmtsearch = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(fmtsearch))' + / ', %str(()) ))));' + / '%end;' + / '%put NOTE- ;'; end; /* create a macro loader for IML modules with dependencies */ @@ -1879,16 +1932,16 @@ data _null_; end; %end; put +(-1) '`.; '' !!' / - ''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !!' / - ''' %put with the SAS Packages Framework version 20251221.; '' !! ' / - ''' %put ****************************************************************************; '' !! ' / + ''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !! ' / + ''' %put with the SAS Packages Framework version 20251231.; '' !! ' / + ''' %put ****************************************************************************; '' !! ' / ''' %GOTO theEndOfTheMacro; '' !! ' / ''' %end; '' !! ' / ''' %local localSYSmacroName localPackageName i depListNm; '' !! ' / ''' %let localSYSmacroName = &sysmacroname.; '' !! ' / ''' %let localSYSmacroName = %sysfunc(lowcase(&localSYSmacroName.)); '' !! ' / - ''' %let localPackageName = %substr(&localSYSmacroName.,1,%eval(%length(&localSYSmacroName.)-3));'' !!' / + ''' %let localPackageName = %substr(&localSYSmacroName.,1,%eval(%length(&localSYSmacroName.)-3));'' !! ' / ''' %if %superq(depList) ne %then '' !!' / ''' %do; '' !!' / @@ -1923,22 +1976,22 @@ data _null_; put "; rc = resolve(IML); run;"; /* wrapper end */ - put '%put NOTE: Macro named:; '; - put '%put %nrstr( %%)' "&packageName." 'IML(); '; - put '%put NOTE- will be generated. Its purpose; '; - put '%put NOTE- is to allow fast load of IML; '; - put '%put NOTE- user defined modules into; '; - put '%put NOTE- the Proc IML session.; '; - put '%put NOTE-; '; - put '%put NOTE- Use it the following way:; '; - put '%put %nrstr( )Proc IML%str(;); '; - put '%put %nrstr( %%)' "&packageName." 'IML(); '; - put '%put %nrstr( )<... your code ...>; '; - put '%put %nrstr( )quit%str(;); '; - put '%put NOTE- ; '; - put '%put NOTE- To get help info run:; '; - put '%put %nrstr( %%)' "&packageName." 'IML(list=HELP);'; - put '%put NOTE-; '; + put '%put NOTE: Macro named:; ' + / '%put %nrstr( %%)' "&packageName." 'IML(); ' + / '%put NOTE- will be generated. Its purpose; ' + / '%put NOTE- is to allow fast load of IML; ' + / '%put NOTE- user defined modules into; ' + / '%put NOTE- the Proc IML session.; ' + / '%put NOTE-; ' + / '%put NOTE- Use it the following way:; ' + / '%put %nrstr( )Proc IML%str(;); ' + / '%put %nrstr( %%)' "&packageName." 'IML(); ' + / '%put %nrstr( )<... your code ...>; ' + / '%put %nrstr( )quit%str(;); ' + / '%put NOTE- ; ' + / '%put NOTE- To get help info run:; ' + / '%put %nrstr( %%)' "&packageName." 'IML(list=HELP);' + / '%put NOTE-; '; put '%end;'; end; @@ -2105,53 +2158,53 @@ data _null_; if isFormat then do; put '%put NOTE- ;'; - put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));'/; + put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /; end; /* update SYSloadedPackages global macrovariable */ - put 'options noNotes;'; - put '%if (%str(*)=%superq(cherryPick)) %then %do; '; /* Cherry Pick test3 start */ - put ' data _null_ ; '; - put ' length SYSloadedPackages stringPCKG $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); '; + put 'options noNotes;' + / '%if (%str(*)=%superq(cherryPick)) %then %do; ' /* Cherry Pick test3 start */ + / ' data _null_ ; ' + / ' length SYSloadedPackages stringPCKG $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); ' - put " indexPCKG = INDEX(lowcase(SYSloadedPackages), '#%sysfunc(lowcase(&packageName.))('); "; - put " if indexPCKG = 0 then "; - put ' do; '; - put " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; '; - put ' end ; '; - put " else "; - put ' do; '; - put " stringPCKG = kscanx(substr(SYSloadedPackages, indexPCKG+1), 1, '#'); "; - put ' SYSloadedPackages = compbl(tranwrd(SYSloadedPackages, strip(stringPCKG), "#")); '; - put " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; '; - put ' end ; '; - put ' end; '; - put ' else '; - put ' do; '; - put " call symputX('SYSloadedPackages', '&packageName.(&packageVersion.)', 'G'); "; - put " put / 'INFO:[SYSLOADEDPACKAGES] &packageName.(&packageVersion.)'; "; - put ' end; '; - put ' stop; '; - put ' run; '; - put '%end; ' / ; /* Cherry Pick test3 end */ + / " indexPCKG = INDEX(lowcase(SYSloadedPackages), '#%sysfunc(lowcase(&packageName.))('); " + / " if indexPCKG = 0 then " + / ' do; ' + / " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; ' + / ' end ; ' + / " else " + / ' do; ' + / " stringPCKG = kscanx(substr(SYSloadedPackages, indexPCKG+1), 1, '#'); " + / ' SYSloadedPackages = compbl(tranwrd(SYSloadedPackages, strip(stringPCKG), "#")); ' + / " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; ' + / ' end ; ' + / ' end; ' + / ' else ' + / ' do; ' + / " call symputX('SYSloadedPackages', '&packageName.(&packageVersion.)', 'G'); " + / " put / 'INFO:[SYSLOADEDPACKAGES] &packageName.(&packageVersion.)'; " + / ' end; ' + / ' stop; ' + / ' run; ' + / '%end; ' / ; /* Cherry Pick test3 end */ - put 'options NOTES;'; - put '%put NOTE- ;'; - put '%put NOTE: '"Loading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; + put 'options NOTES;' + / '%put NOTE- ;' + / '%put NOTE: '"Loading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' /; put 'options &temp_noNotes_etc.;' / '%symdel temp_noNotes_etc / noWarn;'; @@ -2170,9 +2223,9 @@ data _null_; file &zipReferrence.(lazydata.sas) lrecl=32767 encoding = &packageEncoding.; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: ' @; put "Data for package &packageName., version &packageVersion., license &packageLicense.; "; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: ' @; put "Data for package &packageName., version &packageVersion., license &packageLicense.; "; put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; @@ -2185,42 +2238,42 @@ data _null_; /*put '%include ' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /;*/ /* <- copied also to loadPackage macro */ - put 'data _null_;'; - put ' length lazyData $ 32767; lazyData = lowcase(symget("lazyData"));'; + put 'data _null_;' + / ' length lazyData $ 32767; lazyData = lowcase(symget("lazyData"));'; do until(eof); set &filesWithCodes. end = EOF nobs=NOBS; if ( upcase(type) =: 'LAZYDATA' ) then do; - put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then'; - put 'do;'; - put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";'; - put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');'; - put 'end;' /; + put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then' + / 'do;' + / ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";' + / ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');' + / 'end;' ; end; /* use lazyData to reload data type */ if ( upcase(type) =: 'DATA' ) then do; - put 'if findw(lazyData, "' fileshort +(-1) '") then'; - put 'do;'; - put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";'; - put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');'; - put 'end;' /; + put 'if findw(lazyData, "' fileshort +(-1) '") then' + / 'do;' + / ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";' + / ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');' + / 'end;' ; end; end; put 'run;'; - put '%put NOTE- ;'; - put '%put NOTE: '"Data for package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* lazydata.sas end */" /; + put '%put NOTE- ;' + / '%put NOTE: '"Data for package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* lazydata.sas end */" ; stop; run; /* unloading package objects */ -%put NOTE-; +%put NOTE-; %put NOTE: Preparing unload file.; %put NOTE- ^^^^^^^^^^^^^^^^^^^^^^; %put NOTE-; @@ -2230,102 +2283,100 @@ data _null_; file &zipReferrence.(unload.sas) encoding = &packageEncoding.; - put "filename &_PackageFileref_. list;" /; - put '%put NOTE: '"Unloading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** START ***;' /; + put "filename &_PackageFileref_. list;" + / '%put NOTE: '"Unloading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** START ***;'; /* include "cleaning" files */ EOF = 0; do until(EOF); set &filesWithCodes. end = EOF nobs = NOBS; if not (upcase(type)=:'CLEAN') then continue; - put '%put NOTE- Code of type ' type 'generated from the file "' file +(-1) '" will be executed;'; - put '%put NOTE- ;' /; - put '%put NOTE- Executing the following code: ;'; - put '%put NOTE- *****************************;'; - put 'data _null_;'; - put " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;'; - put ' input;'; - put ' putlog "*> " _infile_;'; - put 'run;' /; - put '%put NOTE- *****************************;'; - put '%put NOTE- ;'; + put '%put NOTE- Code of type ' type 'generated from the file "' file +(-1) '" will be executed;' + / '%put NOTE- ;' + / '%put NOTE- Executing the following code: ;' + / '%put NOTE- *****************************;' + / 'data _null_;' + / " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;' + / ' input;' + / ' putlog "*> " _infile_;' + / 'run;' + / '%put NOTE- *****************************;' + / '%put NOTE- ;'; put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /; end; /* delete macros and formats */ - put 'proc sql;'; - put ' create table WORK._%sysfunc(datetime(), hex16.)_ as'; - put ' select memname, objname, objtype'; - put ' from dictionary.catalogs'; - put ' where '; - put ' ('; - put ' objname in ("*"' ; - put " ,%UPCASE('&packageName.IML')" ; - put " ,%UPCASE('&packageName.CASLUDF')" /; + put 'proc sql;' + / ' create table WORK._%sysfunc(datetime(), hex16.)_ as' + / ' select memname, objname, objtype' + / ' from dictionary.catalogs' + / ' where ' + / ' (' + / ' objname in ("*"' + / " ,%UPCASE('&packageName.IML')" + / " ,%UPCASE('&packageName.CASLUDF')"; /* list of macros */ EOF = 0; do until(EOF); set &filesWithCodes. end = EOF nobs = NOBS; if not (upcase(type)=:'MACRO') then continue; - put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put ' %put NOTE- ;'; - put ' ,"' fileshort upcase64. '"' /; + put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / ' %put NOTE- ;' + / ' ,"' fileshort upcase64. '"'; end; /**/ - put ' )'; - put ' and objtype = "MACRO"'; - put ' and libname = "WORK"'; - put ' )'; - put ' or'; - put ' ('; - put ' objname in ("*"' /; + put ' )' + / ' and objtype = "MACRO"' + / ' and libname = "WORK"' + / ' )' + / ' or' + / ' (' + / ' objname in ("*"'; /* list of formats */ isFormat = 0; EOF = 0; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'FORMAT') then continue; - put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put ' %put NOTE- ;'; - put ' ,"' fileshort upcase64. '"' /; + put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / ' %put NOTE- ;' + / ' ,"' fileshort upcase64. '"'; isFormat + 1; end; - put ' )'; - put ' and objtype in ("FORMAT" "FORMATC" "INFMT" "INFMTC")'; - put ' and libname = "WORK"'; - put " and memname = '%upcase(&packageName.format)'"; - put ' )'; - - put ' order by objtype, memname, objname'; - put ' ;'; - put 'quit;'; - - put 'data _null_;'; - put ' do until(last.memname);'; - put ' set WORK._last_;'; - put ' by objtype memname;'; - put ' if first.memname then call execute("proc catalog cat = work." !! strip(memname) !! " force;");'; - put ' call execute("delete " !! strip(objname) !! " / et =" !! objtype !! "; run;");'; - put ' end;'; - put ' call execute("quit;");'; - put 'run;'; - put 'proc delete data = WORK._last_;'; - put 'run;'; + put ' )' + / ' and objtype in ("FORMAT" "FORMATC" "INFMT" "INFMTC")' + / ' and libname = "WORK"' + / " and memname = '%upcase(&packageName.format)'" + / ' )' + / ' order by objtype, memname, objname' + / ' ;' + / 'quit;' + / 'data _null_;' + / ' do until(last.memname);' + / ' set WORK._last_;' + / ' by objtype memname;' + / ' if first.memname then call execute("proc catalog cat = work." !! strip(memname) !! " force;");' + / ' call execute("delete " !! strip(objname) !! " / et =" !! objtype !! "; run;");' + / ' end;' + / ' call execute("quit;");' + / 'run;' + / 'proc delete data = WORK._last_;' + / 'run;'; /* delete the link to the formats catalog */ if isFormat then do; - put "proc delete data = work.&packageName.format(mtype = catalog);"; - put 'run;'; - put 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));'; - put 'options fmtsearch = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(fmtsearch))' / - ', %str(()) ))));'; - put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /; + put "proc delete data = work.&packageName.format(mtype = catalog);" + / 'run;' + / 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));' + / 'options fmtsearch = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(fmtsearch))' + / ', %str(()) ))));' + / '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));'; end; /* delete proto functions */ @@ -2334,22 +2385,22 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'PROTO') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' /; isProto + 1; end; /* delete the link to the proto functions dataset */ if isProto then do; - put "proc delete data = work.&packageName.proto;"; - put "run;" /; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /; + put "proc delete data = work.&packageName.proto;" + / "run;" + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));'; end; @@ -2360,9 +2411,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'FUNCTION') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;'; - put 'deletefunc ' fileshort ';' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' + / 'deletefunc ' fileshort ';'; isFunction + 1; end; put "run;" /; @@ -2370,13 +2421,13 @@ data _null_; /* delete the link to the functions dataset */ if isFunction then do; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /; + put 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));'; end; /* delete IML modules */ @@ -2386,12 +2437,12 @@ data _null_; if not (upcase(type)=:'IMLMODULE') then continue; if first.iml then do; - put "proc delete lib=WORK data=&packageName.IML (memtype=catalog); "; - put "run; "; + put "proc delete lib=WORK data=&packageName.IML (memtype=catalog); " + / "run; "; first.IML = 0; end; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' /; /* put 'remove module = ' fileshort ';'; */ end; @@ -2401,9 +2452,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type) in: ('DATA')) then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;'; - put '%sysfunc(ifc(%sysfunc(exist(' fileshort ')),drop table ' fileshort ',));' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' + / '%sysfunc(ifc(%sysfunc(exist(' fileshort ')),drop table ' fileshort ',));'; end; put "quit;" /; @@ -2430,9 +2481,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'LIBNAME') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be cleared;'; - put '%put NOTE- ;'; - put 'libname ' fileshort ' clear;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be cleared;' + / '%put NOTE- ;' + / 'libname ' fileshort ' clear;'; end; put "run;" /; @@ -2441,46 +2492,45 @@ data _null_; length packageReqPackages $ 32767; packageReqPackages = lowcase(symget('packageReqPackages')); /* note to unload required packages */ - put 'data _null_ ; '; - put ' length req name $ 64; '; - put ' put "NOTE-" / "NOTE: To unload additional required SAS packages execute: " / "NOTE-"; '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' name = strip(kscanx(req, 1, "(")); '; - put ' put '' %unloadPackage( '' name ")" ; '; - put ' end ; '; - put ' put "NOTE-" / "NOTE-"; stop; '; - put 'run; ' /; + put 'data _null_ ; ' + / ' length req name $ 64; ' + / ' put "NOTE-" / "NOTE: To unload additional required SAS packages execute: " / "NOTE-"; ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' name = strip(kscanx(req, 1, "(")); ' + / ' put '' %unloadPackage( '' name ")" ; ' + / ' end ; ' + / ' put "NOTE-" / "NOTE-"; stop; ' + / 'run; '; %end; /* update SYSloadedPackages global macrovariable */ - put 'data _null_ ; '; - put ' length SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); '; - - put " if INDEX(lowcase(SYSloadedPackages),'#%sysfunc(lowcase(&packageName.(&packageVersion.)))#')>0 then "; - put ' do; '; - put " SYSloadedPackages = tranwrd(SYSloadedPackages, '#&packageName.(&packageVersion.)#', '##'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put "NOTE: " SYSloadedPackages = ; '; - put ' end ; '; - put ' end; '; - put ' stop; '; - put 'run; ' / ; + put 'data _null_ ; ' + / ' length SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); ' + / " if INDEX(lowcase(SYSloadedPackages),'#%sysfunc(lowcase(&packageName.(&packageVersion.)))#')>0 then " + / ' do; ' + / " SYSloadedPackages = tranwrd(SYSloadedPackages, '#&packageName.(&packageVersion.)#', '##'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put "NOTE: " SYSloadedPackages = ; ' + / ' end ; ' + / ' end; ' + / ' stop; ' + / 'run; ' - put '%put NOTE: ' "Unloading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;'; - put '%put NOTE- ;' /; + / '%put NOTE: ' "Unloading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / '%put NOTE- ;' - put "/* unload.sas end */"; + / "/* unload.sas end */"; stop; run; @@ -2496,50 +2546,50 @@ data _null_; file &zipReferrence.(preview.sas) encoding = &packageEncoding.; length strX $ 32767; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;"; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;" - put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; - put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; - put ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); '; - put ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); '; - put ' %put NOTE- ;'; - put ' %put NOTE- *** START ***;' /; + / ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; ' + / ' %put NOTE- ' @; put "Generated: &packageGenerated.; " + / ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); ' + / ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); ' + / ' %put NOTE- ;' + / ' %put NOTE- *** START ***;'; /* Use helpKeyword macrovariable to search for content (filename and type) */ /* put '%local ls_tmp ps_tmp notes_tmp source_tmp; ';*/ - put '%let ls_tmp = %sysfunc(getoption(ls)); '; - put '%let ps_tmp = %sysfunc(getoption(ps)); '; - put '%let notes_tmp = %sysfunc(getoption(notes)); '; - put '%let source_tmp = %sysfunc(getoption(source)); '; - put 'options ls = MAX ps = MAX nonotes nosource; '; - put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /; + put '%let ls_tmp = %sysfunc(getoption(ls)); ' + / '%let ps_tmp = %sysfunc(getoption(ps)); ' + / '%let notes_tmp = %sysfunc(getoption(notes)); ' + / '%let source_tmp = %sysfunc(getoption(source)); ' + / 'options ls = MAX ps = MAX nonotes nosource; ' + / '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " - put 'data _null_; '; - put ' if strip(symget("helpKeyword")) = " " then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(description.sas) end = EOF; "; - put ' input; '; - put ' put _infile_; '; - put ' end; '; - put ' else stop; '; - put 'run; ' /; + / 'data _null_; ' + / ' if strip(symget("helpKeyword")) = " " then ' + / ' do until (EOF); ' + / " infile &_PackageFileref_.(description.sas) end = EOF; " + / ' input; ' + / ' put _infile_; ' + / ' end; ' + / ' else stop; ' + / 'run; ' - put 'data WORK._%sysfunc(datetime(), hex16.)_; '; - put 'infile cards4 dlm = "/"; '; - put 'input @; '; - put 'if 0 then output; '; - put 'length helpKeyword $ 64; '; - put 'retain helpKeyword "*"; '; - put 'drop helpKeyword; '; - put 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); '; - put 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then '; - put ' do; '; - put ' input (folder order type file fileshort) (: $ 256.); '; - put ' output; '; - put ' end; '; - put 'cards4; '; + / 'data WORK._%sysfunc(datetime(), hex16.)_; ' + / 'infile cards4 dlm = "/"; ' + / 'input @; ' + / 'if 0 then output; ' + / 'length helpKeyword $ 64; ' + / 'retain helpKeyword "*"; ' + / 'drop helpKeyword; ' + / 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); ' + / 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then ' + / ' do; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / ' end; ' + / 'cards4; '; EOFDS = 0; do until(EOFDS); @@ -2562,42 +2612,42 @@ data _null_; put strX; end; - put ";;;;"; - put "run;" /; + put ";;;;" + / "run;"; /* loop through content found and print info to the log */ - put 'data _null_; '; - put 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; '; - put 'if NOBS = 0 then do; ' / - 'put; put '' *> No preview. Try %previewPackage(packageName,*) to display all.''; put; stop; ' / - 'end; '; - put ' do until(EOFDS); '; - put ' set WORK._last_ end = EOFDS nobs = NOBS; '; - put ' length memberX $ 1024; '; - put ' memberX = cats("_",folder,".",file); '; + put 'data _null_; ' + / 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; ' + / 'if NOBS = 0 then do; ' + / 'put; put '' *> No preview. Try %previewPackage(packageName,*) to display all.''; put; stop; ' + / 'end; ' + / ' do until(EOFDS); ' + / ' set WORK._last_ end = EOFDS nobs = NOBS; ' + / ' length memberX $ 1024; ' + / ' memberX = cats("_",folder,".",file); ' /* inner data step in call execute to read each embedded file */ - put ' call execute("data _null_; ");'; - put " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');"; - put ' call execute(" do until(EOF); ");'; - put ' call execute(" input; ");'; - put ' call execute(" put _infile_; ");'; - put ' call execute(" end; ");'; - put ' call execute(" put "" "" / "" ""; ");'; - put ' call execute(" stop; ");'; - put ' call execute("run; ");'; + / ' call execute("data _null_; ");' + / " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');" + / ' call execute(" do until(EOF); ");' + / ' call execute(" input; ");' + / ' call execute(" put _infile_; ");' + / ' call execute(" end; ");' + / ' call execute(" put "" "" / "" ""; ");' + / ' call execute(" stop; ");' + / ' call execute("run; ");' /**/ - put " end; "; - put " stop; "; - put "run; "; + / " end; " + / " stop; " + / "run; " /* clean-up */ - put "proc delete data = WORK._last_; "; - put "run; "; - put 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' /; + / "proc delete data = WORK._last_; " + / "run; " + / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' - put '%put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* preview.sas end */"; + / '%put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* preview.sas end */"; stop; run; @@ -2614,37 +2664,36 @@ data _null_; file &zipReferrence.(help.sas) encoding = &packageEncoding.; length strX $ 32767; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;"; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;" - put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; - put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; - put ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); '; - put ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); '; - put ' %put NOTE- ;'; - put ' %put NOTE- *** START ***;' /; + / ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; ' + / ' %put NOTE- ' @; put "Generated: &packageGenerated.; " + / ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); ' + / ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); ' + / ' %put NOTE- ;' + / ' %put NOTE- *** START ***;' /* Use helpKeyword macrovariable to search for content (filename and type) */ /* put '%local ls_tmp ps_tmp notes_tmp source_tmp; ';*/ - put '%let ls_tmp = %sysfunc(getoption(ls)); '; - put '%let ps_tmp = %sysfunc(getoption(ps)); '; - put '%let notes_tmp = %sysfunc(getoption(notes)); '; - put '%let source_tmp = %sysfunc(getoption(source)); '; - put 'options ls = MAX ps = MAX nonotes nosource; '; - put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /; - - put 'data _null_; '; - put ' if strip(symget("helpKeyword")) = " " then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(description.sas) end = EOF; "; - put ' input; '; - put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; '; - put ' if printer then put "| " _infile_; '; - put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; '; - put ' end; '; - put ' else stop; '; + / '%let ls_tmp = %sysfunc(getoption(ls)); ' + / '%let ps_tmp = %sysfunc(getoption(ps)); ' + / '%let notes_tmp = %sysfunc(getoption(notes)); ' + / '%let source_tmp = %sysfunc(getoption(source)); ' + / 'options ls = MAX ps = MAX nonotes nosource; ' + / '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " + / 'data _null_; ' + / ' if strip(symget("helpKeyword")) = " " then ' + / ' 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; ' + / ' else stop; '; put ' put ; put " Package contains: "; '; EOFDS = 0; @@ -2660,34 +2709,34 @@ data _null_; %do; length packageRequired $ 32767; packageRequired = symget('packageRequired'); - put ' length req $ 256; '; - put ' put ; put " Required SAS Components: "; '; - put ' do req = ' / packageRequired / ' ; '; - put ' put @3 "-" @5 req; '; - put ' end ; '; + put ' length req $ 256; ' + / ' put ; put " Required SAS Components: "; ' + / ' do req = ' / packageRequired / ' ; ' + / ' put @3 "-" @5 req; ' + / ' end ; '; %end; %if %superq(packageReqPackages) ne %then %do; length packageReqPackages $ 32767; packageReqPackages = symget('packageReqPackages'); - put ' length req $ 256; '; - put ' put ; put " Required SAS Packages: "; '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' put @3 "-" @5 req; '; - put ' end ; '; + put ' length req $ 256; ' + / ' put ; put " Required SAS Packages: "; ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' put @3 "-" @5 req; ' + / ' end ; '; %end; %if %superq(additionalContent) NE %then %do; - put 'put ;' / 'put @3 ''Package contains additional content, run: %loadPackageAddCnt(' "&packageName." ') to load it'';'; - put "put @3 'or look for the %sysfunc(lowcase(&packageName.))_AdditionalContent directory in the Packages fileref';"; - put "put @3 'localization (only if additional content was deployed during the installation process).';" / "put ;"; + put 'put ;' / 'put @3 ''Package contains additional content, run: %loadPackageAddCnt(' "&packageName." ') to load it'';' + / "put @3 'or look for the %sysfunc(lowcase(&packageName.))_AdditionalContent directory in the Packages fileref';" + / "put @3 'localization (only if additional content was deployed during the installation process).';" / "put ;"; %end; put 'put " " / @3 "---------------------------------------------------------------------" / " ";' - / 'put @3 "*SAS package generated by SAS Package Framework, version `20251221`*";' + / 'put @3 "*SAS package generated by SAS Package Framework, version `20251231`*";' / "put @3 '*under `&sysscp.`(`&sysscpl.`) operating system,*';" / "put @3 '*using SAS release: `&sysvlong4.`.*';" / 'put " " / @3 "---------------------------------------------------------------------";'; @@ -2695,30 +2744,30 @@ data _null_; put 'run; ' /; /* license info */ - put 'data _null_; '; - put ' if upcase(strip(symget("helpKeyword"))) = "LICENSE" then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(license.sas) end = EOF; "; - put ' input; '; - put ' put "| " _infile_; '; - put ' end; '; - put ' else stop; '; - put 'run; ' /; + put 'data _null_; ' + / ' if upcase(strip(symget("helpKeyword"))) = "LICENSE" then ' + / ' do until (EOF); ' + / " infile &_PackageFileref_.(license.sas) end = EOF; " + / ' input; ' + / ' put "| " _infile_; ' + / ' end; ' + / ' else stop; ' + / 'run; '; - put 'data WORK._%sysfunc(datetime(), hex16.)_; '; - put 'infile cards4 dlm = "/"; '; - put 'input @; '; - put 'if 0 then output; '; - put 'length helpKeyword $ 64; '; - put 'retain helpKeyword "*"; '; - put 'drop helpKeyword; '; - put 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); '; - put 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then '; - put ' do; '; - put ' input (folder order type file fileshort) (: $ 256.); '; - put ' output; '; - put ' end; '; - put 'cards4; '; + put 'data WORK._%sysfunc(datetime(), hex16.)_; ' + / 'infile cards4 dlm = "/"; ' + / 'input @; ' + / 'if 0 then output; ' + / 'length helpKeyword $ 64; ' + / 'retain helpKeyword "*"; ' + / 'drop helpKeyword; ' + / 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); ' + / 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then ' + / ' do; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / ' end; ' + / 'cards4; '; EOFDS = 0; do until(EOFDS); @@ -2749,55 +2798,55 @@ data _null_; put 'run;'; */ /* loop through content found and print info to the log */ - put 'data _null_; '; - put 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; '; - put 'if NOBS = 0 then do; ' / - 'put; put '' *> No help info found. Try %helpPackage(packageName,*) to display all.''; put; stop; ' / - 'end; '; - put ' do until(EOFDS); '; - put ' set WORK._last_ end = EOFDS nobs = NOBS; '; - put ' length memberX $ 1024; '; - put ' memberX = cats("_",folder,".",file); '; + put 'data _null_; ' + / 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; ' + / 'if NOBS = 0 then do; ' + / 'put; put '' *> No help info found. Try %helpPackage(packageName,*) to display all.''; put; stop; ' + / 'end; ' + / ' do until(EOFDS); ' + / ' set WORK._last_ end = EOFDS nobs = NOBS; ' + / ' length memberX $ 1024; ' + / ' memberX = cats("_",folder,".",file); ' /* inner data step in call execute to read each embedded file */ - put ' call execute("data _null_; ");'; - put " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');"; - put ' call execute(" printer = 0; ");'; - put ' call execute(" do until(EOF); ");'; - put ' call execute(" input; ");'; - put ' call execute(" _endhelpline_ = upcase(reverse(strip(_infile_))); ");'; - put ' call execute(" if 18 <= lengthn(_endhelpline_) AND _endhelpline_ '; - put ' =: ''/*** DNE PLEH ***/'' then printer = 0; ");'; /* ends with HELP END */ - put ' call execute(" if printer then put ""| "" _infile_; ");'; - put ' call execute(" _starthelpline_ = upcase(strip(_infile_)); ");'; - put ' call execute(" if 20 <= lengthn(_starthelpline_) AND _starthelpline_ '; - put ' =: ''/*** HELP START ***/'' then printer = 1; ");'; /* starts with HELP START */ - put ' call execute(" end; ");'; - put ' call execute(" put "" "" / "" ""; ");'; - put ' call execute(" stop; ");'; - put ' call execute("run; ");'; - put ' if lowcase(type) in ("data" "lazydata") then '; - put ' do; '; - put ' call execute("title ""Dataset " || strip(fileshort) || " from package &packageName. ""; ");'; - put ' if exist(fileshort) then call execute("proc contents data = " || strip(fileshort) || "; run; ");'; - put ' else call execute("data _null_; put ""| Dataset " || strip(fileshort) || " does not exist.""; run;");'; - put ' call execute("title; ");'; - put ' end; '; + / ' call execute("data _null_; ");' + / " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');" + / ' call execute(" printer = 0; ");' + / ' call execute(" do until(EOF); ");' + / ' call execute(" input; ");' + / ' 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(" stop; ");' + / ' call execute("run; ");' + / ' if lowcase(type) in ("data" "lazydata") then ' + / ' do; ' + / ' call execute("title ""Dataset " || strip(fileshort) || " from package &packageName. ""; ");' + / ' if exist(fileshort) then call execute("proc contents data = " || strip(fileshort) || "; run; ");' + / ' else call execute("data _null_; put ""| Dataset " || strip(fileshort) || " does not exist.""; run;");' + / ' call execute("title; ");' + / ' end; ' /**/ - put " end; "; - put " stop; "; - put "run; "; + / " end; " + / " stop; " + / "run; "; /* clean up */ - put "proc delete data = WORK._last_; "; - put "run; "; + put "proc delete data = WORK._last_; " + / "run; "; /* generate dataset witch content information */ - put 'data &packageContentDS. _NULL_; ' - / ' if "&packageContentDS." = " " then stop; ' - / ' infile cards4 dlm = "/"; ' - / ' input (folder order type file fileshort) (: $ 256.); ' - / ' output; ' - / 'cards4; ' + put 'data &packageContentDS. _NULL_; ' + / ' if "&packageContentDS." = " " then stop; ' + / ' infile cards4 dlm = "/"; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / 'cards4; ' ; EOFDS = 0; @@ -2811,12 +2860,11 @@ data _null_; put ";;;;" / "run;" - / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' - / ; + / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; '; - put '%put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* help.sas end */"; + put '%put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* help.sas end */"; stop; run; @@ -2841,7 +2889,7 @@ data _null_; if (upcase(type) not in: ('TEST' 'ADDCNT')); /* test files and additional content are not to be copied */ call execute(cat ('filename _SPFIN_ "', catx('/', base, folder, file), '";')); - call execute(cats("filename _SPFOUT_ ZIP '", base, "/%sysfunc(lowcase(&packageName.)).zip' member='_", folder, ".", file, "';") ); + call execute(cats("filename _SPFOUT_ ZIP '", build, "/%sysfunc(lowcase(&packageName.)).zip' member='_", folder, ".", file, "';") ); /* copy code file into the zip */ call execute('data _null_;'); @@ -2896,7 +2944,7 @@ data _null_; "help " ; /* test if "driving" files exist */ - call execute(cats("filename _SPFOUT_ ZIP '", base, "/%sysfunc(lowcase(&packageName.)).zip' member='", drivFile, ".sas';") ); + call execute(cats("filename _SPFOUT_ ZIP '", build, "/%sysfunc(lowcase(&packageName.)).zip' member='", drivFile, ".sas';") ); call execute('data _null_;'); call execute(' pathname = pathname("_SPFIN_");'); call execute(' ex = fexist("_SPFOUT_");'); @@ -3033,7 +3081,7 @@ filename &zipReferrence. clear; %put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^; %put NOTE-; - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; + filename &zipReferrence. "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; filename &zipReferrence. list; %local notesSourceOptions; %let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source)); @@ -3063,931 +3111,41 @@ filename &zipReferrence. clear; options ¬esSourceOptions.; filename &zipReferrence. clear; %end; -/*-+++++++++++++++++++++++-*/ - -/* 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 %bquote(&testPackage.) ne Y %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=&filesLocation.)" /; - put @n '%loadpackage'"(&packageName.,"; - put @n " path=&filesLocation., lazyData=*)" /; - - /* help */ - put @n '%helpPackage'"(&packageName.,"; - put @n " path=&filesLocation.)" /; - put @n '%helpPackage'"(&packageName.,*,"; - put @n " path=&filesLocation.)" /; - put @n '%helpPackage'"(&packageName.,License,"; - put @n " path=&filesLocation.)" /; - - /* preview */ - put @n '%previewPackage'"(&packageName.,"; - put @n " path=&filesLocation.)" /; - put @n '%previewPackage'"(&packageName.,*,"; - put @n " path=&filesLocation.)" /; - - /* unload */ - put @n '%unloadPackage'"(&packageName.,"; - put @n " path=&filesLocation.) " /; - - /* additional content */ - put @n '%loadPackageAddCnt'"(&packageName.,"; - put @n " path=&filesLocation.) " /; - - put ; - put '***************************************************'; - run; - - %GOTO NOTESTING; - %end; - - -/* locate sas binaries */ +/*---------------------------------------------------------------- * +* * +* tests for a package are encapsulated in the next macro * +* * +* ---------------------------------------------------------------- */ +/* 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; +/* location for test and test work */ %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 filesLocation is used as a replacement */ -%if %bquote(&packages.)= %then %let packages=%sysfunc(pathname(packages)); -%if %bquote(&packages.)= %then %let packages=&filesLocation.; -%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=&filesLocation.)" /; - put '%loadpackage'"(&packageName.," - / " path=&filesLocation., lazyData=*)" /; - - /* help */ - put '%helpPackage'"(&packageName.," - / " path=&filesLocation.)" /; - put '%helpPackage'"(&packageName.,*," - / " path=&filesLocation.)" /; - put '%helpPackage'"(&packageName.,License," - / " path=&filesLocation.)" /; - - /* preview */ - put '%previewPackage'"(&packageName.,"; - put " path=&filesLocation.)" /; - put '%previewPackage'"(&packageName.,*,"; - put " path=&filesLocation.)" /; - - /*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=&filesLocation.) " /; - - /* additional content */ - put '%loadPackageAddCnt'"(&packageName.," - / " path=&filesLocation.) " /; - - put "filename packages '&filesLocation.';" - / '%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 ¬esSourceOptions.; -/*-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=&filesLocation.)" /; - put '%loadpackage'"(&packageName.,"; - put " path=&filesLocation., 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 ¬esSourceOptions.; -%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 "elenmax_tmp.; - -/* if you do not want any test to be executed */ -%NOTESTING: - -/* generate MarkDown documentation file */ -/* check param value */ -%if %superq(markdownDoc) NE 1 %then %let markdownDoc=0; -/* if true then execute */ -%if %superq(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. "&filesLocation./%sysfunc(lowcase(&packageName.)).md"; -filename &_PackageFileref_. ZIP "&filesLocation./%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 `20251221`,*" - / "*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) !! ' ######'';'); - 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 ######' / " " - ; - 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.; - -/* 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; - - /* zip */ - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).zip" lrecl=1 recfm=n; - filename &zipReferrence. list; - filename &zipReferrenceV. "&filesLocation./%sysfunc(lowcase(&packageName.))_&packageVersion._.zip" lrecl=1 recfm=n; - filename &zipReferrenceV. list; - data _null_; - 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._.zip file."; - put rctxt; - end; - else put "Creating %sysfunc(lowcase(&packageName.))_&packageVersion._.zip file."; - run; - filename &zipReferrence. clear; - filename &zipReferrenceV. clear; - - /* md */ - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).md" lrecl=1 recfm=n; - filename &zipReferrence. list; - filename &zipReferrenceV. "&filesLocation./%sysfunc(lowcase(&packageName.))_&packageVersion._.md" lrecl=1 recfm=n; - filename &zipReferrenceV. list; - data _null_; - 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._.md file."; - put rctxt; - end; - else put "Creating %sysfunc(lowcase(&packageName.))_&packageVersion._.md file."; - run; - filename &zipReferrence. clear; - filename &zipReferrenceV. clear; - - options ¬esSourceOptions.; -%end; -/*= generate MarkDown documentation END =================================================================================*/ -%NOmarkdownDoc: -%end; +%SPFint_gnPckg_tests() + +/*------------------------------------------------------------------- * +* * +* markdown documentation generation is encapsulated in the next macro * +* * +* ------------------------------------------------------------------- */ +%SPFint_gnPckg_markdown() + +/*-------------------------------------------------------------------- * +* * +* copying (with version in the name) is encapsulated in the next macro * +* * +* -------------------------------------------------------------------- */ +%SPFint_gnPckg_arch() /* clean temporary files */ @@ -4008,73 +3166,10 @@ quit; /* turn on the original value of the note about quoted string length */ options &qlenmax_fstimer_tmp.; - - %ENDofgeneratePackage: %put --- generatePackage END ---; %mend generatePackage; -/* -TODO: (in Polish) - -- modyfikacja helpa, sprawdzanie kodu danej funkcji/makra/typu [v] - -- opcjonalne sortowanie nazw folderow(_) [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 ***/ +/* START macros extracted outside generatePackage macro */ diff --git a/SPF/Macros/helppackage.sas b/SPF/Macros/helppackage.sas index 395abb6..455a048 100644 --- a/SPF/Macros/helppackage.sas +++ b/SPF/Macros/helppackage.sas @@ -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 #; diff --git a/SPF/Macros/installpackage.sas b/SPF/Macros/installpackage.sas index 7b654b5..492237f 100644 --- a/SPF/Macros/installpackage.sas +++ b/SPF/Macros/installpackage.sas @@ -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 #; diff --git a/SPF/Macros/ispackagesfilerefok.sas b/SPF/Macros/ispackagesfilerefok.sas index a422ff8..d3b0291 100644 --- a/SPF/Macros/ispackagesfilerefok.sas +++ b/SPF/Macros/ispackagesfilerefok.sas @@ -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 #; diff --git a/SPF/Macros/listpackages.sas b/SPF/Macros/listpackages.sas index d0f78ef..17e00c5 100644 --- a/SPF/Macros/listpackages.sas +++ b/SPF/Macros/listpackages.sas @@ -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 diff --git a/SPF/Macros/loadpackage.sas b/SPF/Macros/loadpackage.sas index 269416e..ccbf78e 100644 --- a/SPF/Macros/loadpackage.sas +++ b/SPF/Macros/loadpackage.sas @@ -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 #; diff --git a/SPF/Macros/loadpackageaddcnt.sas b/SPF/Macros/loadpackageaddcnt.sas index ea61a23..8800448 100644 --- a/SPF/Macros/loadpackageaddcnt.sas +++ b/SPF/Macros/loadpackageaddcnt.sas @@ -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 #; diff --git a/SPF/Macros/loadpackages.sas b/SPF/Macros/loadpackages.sas index d549552..968a032 100644 --- a/SPF/Macros/loadpackages.sas +++ b/SPF/Macros/loadpackages.sas @@ -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 #; diff --git a/SPF/Macros/previewpackage.sas b/SPF/Macros/previewpackage.sas index 72f1a09..694654f 100644 --- a/SPF/Macros/previewpackage.sas +++ b/SPF/Macros/previewpackage.sas @@ -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 #; diff --git a/SPF/Macros/relocatepackage.sas b/SPF/Macros/relocatepackage.sas index 41d3913..99d1b52 100644 --- a/SPF/Macros/relocatepackage.sas +++ b/SPF/Macros/relocatepackage.sas @@ -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; diff --git a/SPF/Macros/saspackagesframeworknotes.sas b/SPF/Macros/saspackagesframeworknotes.sas index 2f9734f..e31080f 100644 --- a/SPF/Macros/saspackagesframeworknotes.sas +++ b/SPF/Macros/saspackagesframeworknotes.sas @@ -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 */ diff --git a/SPF/Macros/spfint_gnpckg_arch.sas b/SPF/Macros/spfint_gnpckg_arch.sas new file mode 100644 index 0000000..b210439 --- /dev/null +++ b/SPF/Macros/spfint_gnpckg_arch.sas @@ -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 ¬esSourceOptions.; +%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(_) [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 ***/ + diff --git a/SPF/Macros/spfint_gnpckg_markdown.sas b/SPF/Macros/spfint_gnpckg_markdown.sas new file mode 100644 index 0000000..be67ffe --- /dev/null +++ b/SPF/Macros/spfint_gnpckg_markdown.sas @@ -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) !! ' ######'';'); + 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 ######' / " " + ; + 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; + + diff --git a/SPF/Macros/spfint_gnpckg_tests.sas b/SPF/Macros/spfint_gnpckg_tests.sas new file mode 100644 index 0000000..ef1fe77 --- /dev/null +++ b/SPF/Macros/spfint_gnpckg_tests.sas @@ -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 ¬esSourceOptions.; +/*-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 ¬esSourceOptions.; +%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 "elenmax_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; + + + diff --git a/SPF/Macros/splitcodeforpackage.sas b/SPF/Macros/splitcodeforpackage.sas index 3b78b67..f89eedd 100644 --- a/SPF/Macros/splitcodeforpackage.sas +++ b/SPF/Macros/splitcodeforpackage.sas @@ -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_; diff --git a/SPF/Macros/unbundlePackages.sas b/SPF/Macros/unbundlePackages.sas new file mode 100644 index 0000000..5f3ca5d --- /dev/null +++ b/SPF/Macros/unbundlePackages.sas @@ -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. + ¬es_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 */ diff --git a/SPF/Macros/unloadpackage.sas b/SPF/Macros/unloadpackage.sas index 04051f5..28e2905 100644 --- a/SPF/Macros/unloadpackage.sas +++ b/SPF/Macros/unloadpackage.sas @@ -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 #; diff --git a/SPF/Macros/verifypackage.sas b/SPF/Macros/verifypackage.sas index 36df5a6..352c59f 100644 --- a/SPF/Macros/verifypackage.sas +++ b/SPF/Macros/verifypackage.sas @@ -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 */ diff --git a/SPF/SPFinit.md b/SPF/SPFinit.md index 486bef1..6e2d4d1 100644 --- a/SPF/SPFinit.md +++ b/SPF/SPFinit.md @@ -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 -------------------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ----------------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ----------------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 ----------------------------------------------------------------------------------------- - 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 ------------------------------------------------------------------------------- - 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 +------------------------------------------------------------------------------- + + 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 +------------------------------------------------------------------------------- + + 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) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ------------------------------------------------------------------------------- diff --git a/SPF/SPFinit.sas b/SPF/SPFinit.sas index d752157..fb7f8e4 100644 --- a/SPF/SPFinit.sas +++ b/SPF/SPFinit.sas @@ -1,7 +1,7 @@ /**############################################################################**/ /* */ -/* Copyright Bartosz Jablonski, since July 2019. */ +/* Copyright Bartosz Jablonski, since July 2019 onward. */ /* */ /* Code is free and open source. If you want - you can use it. */ /* I tested it the best I could */ @@ -43,13 +43,22 @@ - to unload, or - to generate SAS packages. - Version 20251221. + Version 20251231. See examples below. 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 a single load.sas file (also embedded inside the zip). + +Contributors: +- Stu Sztukowski + LinkedIn: https://www.linkedin.com/in/statsguy/ + GitHub: https://github.com/stu-code +- Ken Nakamatsu + LinkedIn: https://www.linkedin.com/in/k-nkmt + GitHub: https://github.com/k-nkmt + */ /*** HELP END ***/ @@ -92,13 +101,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)) ; @@ -108,7 +117,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 #; @@ -385,12 +394,12 @@ minoperator */ )/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)) ; @@ -400,7 +409,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 #; @@ -553,12 +562,12 @@ des = 'Macro to unload SAS package, version 20251221. Run %unloadPackage() for h */ )/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)) ; @@ -568,7 +577,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 #; @@ -711,7 +720,7 @@ TODO: */ /*+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 @@ -738,12 +747,12 @@ TODO: /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)) ; @@ -753,7 +762,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 #; @@ -1405,7 +1414,7 @@ des = 'Macro to install SAS package, version 20251221. Run %%installPackage() fo 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 @@ -1425,12 +1434,12 @@ des = 'Macro to install SAS package, version 20251221. Run %%installPackage() fo %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)) ; @@ -1440,7 +1449,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 #; @@ -1495,7 +1504,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 @@ -1592,7 +1601,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; Macro to generate SAS packages. - Version 20251221 + Version 20251231 A SAS package is a zip file containing a group of SAS codes (macros, functions, data steps generating @@ -1607,7 +1616,9 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; %macro generatePackage( filesLocation /* location of package files - e.g. /path/to/package/files/locatiion or C:\my\package\files */ + e.g. /path/to/package/files/location or C:\my\package\files */ +,buildLocation= /* location of package ZIP file and md (optional) + when empty takes filesLocation */ /* testing options: */ ,testPackage=Y /* indicator if tests should be executed, default value Y means "execute tests" */ @@ -1636,9 +1647,11 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ,easyArch=0 /* when creating documentation file indicates if a copy of the zip and markdown files with the version number in the file name be created */ +,archLocation= /* location for package ZIP files and md (optional) archive + when empty takes buildLocation */ )/ secure minoperator /*** HELP END ***/ -des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() for help info.' +des = 'Macro to generate SAS packages, version 20251231. Run %generatePackage() for help info.' ; %if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then %do; @@ -1653,7 +1666,7 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put ### This is short help information for the `generatePackage` macro #; %put #------------------------------------------------------------------------------------#; %put # #; - %put # Macro to generate SAS packages, version `20251221` #; + %put # Macro to generate 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 #; @@ -1678,6 +1691,10 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put # `%nrstr(%%generatePackage(filesLocation=/path/to/packagename))` #; %put # If empty displays this help information. #; %put # #; + %put # - `buildLocation=` Points to a location where the ZIP file with the package #; + %put # should be generated. If the value is null (default) #; + %put # the `filesLocation=` value is used. #; + %put # #; %put # Testing parameters: #; %put # #; %put # - `testPackage=` Indicator if tests should be executed. #; @@ -1728,6 +1745,9 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %put # The default value: `0` means "do not create files". #; %put # Available values are `0` and `1`. #; %put # #; + %put # - `archLocation=` Location for versioned package ZIP file (if `easyArch=1`) #; + %put # If empty (default) the `buildLocation` value is used. #; + %put # #; %put #------------------------------------------------------------------------------------#; %put ######################################################################################; %put ; @@ -1744,7 +1764,44 @@ des = 'Macro to generate SAS packages, version 20251221. Run %generatePackage() %let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_; %let _DESCR_ = _%sysfunc(datetime(), hex6.)d; %let _LIC_ = _%sysfunc(datetime(), hex6.)l; -%let _DUMMY_ = _%sysfunc(datetime(), hex6.)_; +%let _DUMMY_ = d%sysfunc(datetime(), hex6.)d; + +/* Verify source existence */ +%if 0=%sysfunc(FILEEXIST(%superq(filesLocation))) %then + %do; + %put ERROR: The %superq(filesLocation) directory does NOT exist!; + %put ERROR- Aborting.; + %abort; + %end; + +/* Determine build location for ZIP and MD(optional) */ +/* Priority: 1. buildLocation, 2. filesLocation */ +/* The buildLocation is used for testing too! */ +%if %sysevalf(%superq(buildLocation)=,boolean) %then + %do; + %let buildLocation = &filesLocation.; + %end; +%else + %do; + %if 0=%sysfunc(FILEEXIST(%superq(buildLocation))) %then + %do; + %put WARNING: The %superq(buildLocation) directory does NOT exist!; + %put WARNING- ; + %put WARNING- The %superq(filesLocation) directory will be used.; + %let buildLocation = &filesLocation.; + %end; + %end; +%put NOTE: Build location is: %superq(buildLocation).; + +data _null_; + length path $ 4096; + do x='filesLocation','buildLocation'; + path = symget(x); + str = kcompress(path,'({[<_ !@#$%^&*-=+/\?"'';:|~`>]})','pdfs'); + if str NE " " then put "NOTE: There are non-ASCII characters in the " x "path: " str + / "NOTE- If you are working with SAS9.4M7 or earlier it may cause problems."; + end; +run; /* collect package metadata from the description.sas file */ filename &_DESCR_. "&filesLocation./description.sas" lrecl = 1024; @@ -1892,11 +1949,11 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024; if tryExcept then do; - put 'ERROR: Your Required list seems to be problematic.'; - put 'ERROR- Check the description.sas file.'; - put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.'; - put 'ERROR- "SAS Component1", "SAS Component2", "SAS Component3"'; - put 'ERROR- Provided value is:'; + put 'ERROR: Your Required list seems to be problematic.' + / 'ERROR- Check the description.sas file.' + / 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.' + / 'ERROR- "SAS Component1", "SAS Component2", "SAS Component3"' + / 'ERROR- Provided value is:'; length R $ 32767; R = symget('packageRequired'); put 'ERROR- ' R; @@ -1942,11 +1999,11 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024; if tryExcept then do; - put 'ERROR: Your ReqPackages list seems to be problematic.'; - put 'ERROR- Check the description.sas file.'; - put 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.'; - put 'ERROR- "Package1 (X.X)", "Package2 (Y.Y)", "Package3 (Z.Z)"'; - put 'ERROR- Provided value is:'; + put 'ERROR: Your ReqPackages list seems to be problematic.' + / 'ERROR- Check the description.sas file.' + / 'ERROR- Expected form is "Quoted" Comma, ..., Separated List, e.g.' + / 'ERROR- "Package1 (X.X)", "Package2 (Y.Y)", "Package3 (Z.Z)"' + / 'ERROR- Provided value is:'; length R $ 32767; R = symget('packageReqPackages'); put 'ERROR- ' R; @@ -1996,27 +2053,27 @@ data _null_; ; if not (version > 0) then do; - put 'ERROR: Package version should be a positive NUMBER.'; - put 'ERROR- Current value is: ' "&packageVersion."; - put 'ERROR- Try something small, e.g. 0.1'; - put 'ERROR- Aborting.'; + put 'ERROR: Package version should be a positive NUMBER.' + / 'ERROR- Current value is: ' "&packageVersion." + / 'ERROR- Try something small, e.g. 0.1' + / 'ERROR- Aborting.'; put; abort; end; run; /* create or replace the ZIP file for package */ -filename &zipReferrence. ZIP "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; +filename &zipReferrence. ZIP "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; %if %sysfunc(fexist(&zipReferrence.)) %then %do; - %put NOTE: Deleting file "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; + %put NOTE: Deleting file "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; %let _RC_ = %sysfunc(fdelete(&zipReferrence.)); %put NOTE: &=_RC_; %end; %if %sysfunc(fexist(&zipReferrence.)) %then %do; - %put ERROR: File "&filesLocation./%sysfunc(lowcase(&packageName.)).zip" cannot be deleted.; + %put ERROR: File "&buildLocation./%sysfunc(lowcase(&packageName.)).zip" cannot be deleted.; %put ERROR- Check if the file is not blocked by another process.; %put ERROR- Aborting.; %abort; @@ -2185,7 +2242,9 @@ data &filesWithCodes.; putlog "NOTE: Generating content dataset: &filesWithCodes.."; putlog "NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; putlog "NOTE- "; - base = "&filesLocation."; + base = "&filesLocation."; /* location for source */ + build = "&buildLocation."; /* location for ZIP */ + length folder file lowcase_name $ 256 folderRef fileRef $ 8; drop lowcase_name; @@ -2249,8 +2308,8 @@ data &filesWithCodes.; file = dread(fileId, j); if file NE lowcase(file) then do; - put 'ERROR: File with code should be named ONLY with low case letters.'; - put 'ERROR- Current value is: ' file; + put 'ERROR: File with code should be named ONLY with low case letters.' + / 'ERROR- Current value is: ' file; lowcase_name = lowcase(file); put 'ERROR- Try to use: ' lowcase_name; put; @@ -2262,9 +2321,9 @@ data &filesWithCodes.; if strip(reverse(file)) in: ('sas.') then output; /* ignore not ".sas" files */ else do; - put "WARNING: Only *.sas files are supported." / - "WARNING- The file: " file "will be ignored." / - "WARNING- "; + put "WARNING: Only *.sas files are supported." + / "WARNING- The file: " file "will be ignored." + / "WARNING- "; end; end; else @@ -2274,10 +2333,10 @@ data &filesWithCodes.; additionalContent+1; if additionalContent > 1 then do; - put "WARNING: Only ONE directory with additional content is allowed!" / - "WARNING- Store all additional content in a single directory." / - "WARNING- The directory: " folder "will be ignored." / - "WARNING- "; + put "WARNING: Only ONE directory with additional content is allowed!" + / "WARNING- Store all additional content in a single directory." + / "WARNING- The directory: " folder "will be ignored." + / "WARNING- "; end; else do; @@ -2358,11 +2417,11 @@ data _null_; /* if number of EXECs and CLEANs differs but both are positive issue a Warning */ if (0 < e < c) or (0 < c < e) or not(EXEC.NUM_ITEMS = CLEAN.NUM_ITEMS = F.NUM_ITEMS) then do; - put "WARNING: Number of EXEC type and CLEAN type files differs!" / - "WARNING- Each EXEC file should have CLEAN file counterpart and vice versa." / - 'WARNING- Please create appropriate files and make your package a "role model".' / - 'WARNING- ' / - 'WARNING- The list of differences:'; + put "WARNING: Number of EXEC type and CLEAN type files differs!" + / "WARNING- Each EXEC file should have CLEAN file counterpart and vice versa." + / 'WARNING- Please create appropriate files and make your package a "role model".' + / 'WARNING- ' + / 'WARNING- The list of differences:'; do while(IF.next()=0); ne = 0; nc = 0; @@ -2376,10 +2435,10 @@ data _null_; /* if EXECs are positive but CLEANs are zero (or other way around) issue an Error */ if (0 = e < c) or (0 = c < e) then do; - put "ERROR: There are " e "EXECs files and " c "CLEANs files!" / - "ERROR- Each EXEC file should have CLEAN file counterpart and vice versa." / - 'ERROR- Please create appropriate files and make your package a "role model".' / - 'ERROR: [&sysmacroname.] Aborting package generation!' ; + put "ERROR: There are " e "EXECs files and " c "CLEANs files!" + / "ERROR- Each EXEC file should have CLEAN file counterpart and vice versa." + / 'ERROR- Please create appropriate files and make your package a "role model".' + / 'ERROR: [&sysmacroname.] Aborting package generation!'; abort; end; end; @@ -2466,6 +2525,8 @@ run; proc contents data = &filesWithCodes.; run; */ +%local _titleNumber_; +%let _titleNumber_=6; title1 "Package location is: &filesLocation."; title2 "User: &SYSUSERID., Datetime: &packageGenerated., SAS version: &SYSVLONG4."; title3 "Package encoding: '&packageEncoding.', Session encoding: '&SYSENCODING.'."; @@ -2476,14 +2537,21 @@ title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_."; or (%superq(packageReqPackages) ne ) %then %do; - title7 "Required SAS licences: %qsysfunc(compress(%superq(packageRequired), %str(%'%")))" ; /* ' */ - title8 "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */ + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Required SAS licences: %qsysfunc(compress(%superq(packageRequired), %str(%'%")))" ; /* ' */ + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */ + %end; +%if %superq(buildLocation) NE %superq(filesLocation) %then + %do; + %let _titleNumber_=%eval(&_titleNumber_.+1); + title&_titleNumber_. "Package ZIP file location is: &buildLocation."; %end; -footnote1 "SAS Packages Framework, version 20251221"; +footnote1 "SAS Packages Framework, version 20251231"; proc print - data = &filesWithCodes.(drop=base folderRef fileRef rc folderid _abort_ fileId additionalContent) + data = &filesWithCodes.(drop=base build folderRef fileRef rc folderid _abort_ fileId additionalContent) width=full ; run; @@ -2548,27 +2616,27 @@ run; file &zipReferrence.(license.sas) encoding = &packageEncoding.; length packageAuthor $ 1024; packageAuthor = symget('packageAuthor'); - put " "; - put "Copyright (c) since %sysfunc(today(),year4.) " packageAuthor ; - put " "; - put "Permission is hereby granted, free of charge, to any person obtaining a copy"; - put 'of this software and associated documentation files (the "Software"), to deal'; - put "in the Software without restriction, including without limitation the rights"; - put "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"; - put "copies of the Software, and to permit persons to whom the Software is"; - put "furnished to do so, subject to the following conditions:"; - put " "; - put "The above copyright notice and this permission notice shall be included"; - put "in all copies or substantial portions of the Software."; - put " "; - put 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR'; - put "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"; - put "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"; - put "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"; - put "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"; - put "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"; - put "SOFTWARE."; - put " "; + put " " + / "Copyright (c) since %sysfunc(today(),year4.) " packageAuthor + / " " + / "Permission is hereby granted, free of charge, to any person obtaining a copy" + / 'of this software and associated documentation files (the "Software"), to deal' + / "in the Software without restriction, including without limitation the rights" + / "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" + / "copies of the Software, and to permit persons to whom the Software is" + / "furnished to do so, subject to the following conditions:" + / " " + / "The above copyright notice and this permission notice shall be included" + / "in all copies or substantial portions of the Software." + / " " + / 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR' + / "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," + / "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" + / "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" + / "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," + / "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" + / "SOFTWARE." + / " "; run; %end; @@ -2598,16 +2666,16 @@ data _null_; packageLicense = quote(strip(symget('packageLicense')),'"'); packageGenerated = quote(strip(symget('packageGenerated')),'"'); - put ' data _null_; '; /* simple "%local" returns error while loading package */ - put ' call symputX("packageName", ' packageName ', "L");'; - put ' call symputX("packageVersion", ' packageVersion ', "L");'; - put ' call symputX("packageTitle", ' packageTitle ', "L");'; - put ' call symputX("packageAuthor", ' packageAuthor ', "L");'; - put ' call symputX("packageMaintainer", ' packageMaintainer ', "L");'; - put ' call symputX("packageEncoding", ' packageEncoding ', "L");'; - put ' call symputX("packageLicense", ' packageLicense ', "L");'; - put ' call symputX("packageGenerated", ' packageGenerated ', "L");'; - put ' run; '; + put ' data _null_; ' /* simple "%local" returns error while loading package */ + / ' call symputX("packageName", ' packageName ', "L");' + / ' call symputX("packageVersion", ' packageVersion ', "L");' + / ' call symputX("packageTitle", ' packageTitle ', "L");' + / ' call symputX("packageAuthor", ' packageAuthor ', "L");' + / ' call symputX("packageMaintainer", ' packageMaintainer ', "L");' + / ' call symputX("packageEncoding", ' packageEncoding ', "L");' + / ' call symputX("packageLicense", ' packageLicense ', "L");' + / ' call symputX("packageGenerated", ' packageGenerated ', "L");' + / ' run; '; stop; run; @@ -2632,82 +2700,76 @@ run; %put NOTE-; data _null_; file &zipReferrence.(iceloadpackage.sas) encoding = &packageEncoding.; - put " "; - put ' /* Temporary replacement of loadPackage() macro. */ '; - put ' %macro ICEloadPackage( '; - put ' packageName /* name of a package */ '; - put ' , path = %sysfunc(pathname(packages)) /* location of a package */ '; - put ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ '; - put ' , zip = zip /* file ext. */ '; - put ' , requiredVersion = . /* required version */ '; - put ' , source2 = /* source2 */ '; - put ' , suppressExec = 0 /* suppress execs */ '; - put ' )/secure; '; - put ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; '; - put ' %local _PackageFileref_; '; - put ' data _null_; '; - put ' call symputX("_PackageFileref_", "P" !! put(MD5(lowcase("&packageName.")), hex7. -L), "L"); '; - put ' run; '; + put " " + / ' /* Temporary replacement of loadPackage() macro. */ ' + / ' %macro ICEloadPackage( ' + / ' packageName /* name of a package */ ' + / ' , path = %sysfunc(pathname(packages)) /* location of a package */ ' + / ' , options = %str(LOWCASE_MEMNAME) /* possible options for ZIP */ ' + / ' , zip = zip /* file ext. */ ' + / ' , requiredVersion = . /* required version */ ' + / ' , source2 = /* source2 */ ' + / ' , suppressExec = 0 /* suppress execs */ ' + / ' )/secure; ' + / ' %PUT ** NOTE: Package ' "&packageName." ' loaded in ICE mode **; ' + / ' %local _PackageFileref_; ' + / ' data _null_; ' + / ' call symputX("_PackageFileref_", "P" !! put(MD5(lowcase("&packageName.")), hex7. -L), "L"); ' + / ' run; ' - put ' filename &_PackageFileref_. &ZIP. '; - put ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) '; - put ' ; '; - put ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; '; - put ' filename &_PackageFileref_. clear; '; + / ' filename &_PackageFileref_. &ZIP. ' + / ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) ' + / ' ; ' + / ' %include &_PackageFileref_.(packagemetadata.sas) / &source2.; ' + / ' filename &_PackageFileref_. clear; ' /* test if required version of package is "good enough" */ - put ' %local rV pV rV0 pV0 rVsign; '; - put ' %let pV0 = %sysfunc(compress(&packageVersion.,.,kd)); '; - put ' %let pV = %sysevalf((%scan(&pV0.,1,.,M)+0)*1e8 '; - put ' + (%scan(&pV0.,2,.,M)+0)*1e4 '; - put ' + (%scan(&pV0.,3,.,M)+0)*1e0); '; - put ' '; - put ' %let rV0 = %sysfunc(compress(&requiredVersion.,.,kd)); '; - put ' %let rVsign = %sysfunc(compress(&requiredVersion.,<=>,k)); '; - put ' %if %superq(rVsign)= %then %let rVsign=<=; '; - put ' %else %if NOT (%superq(rVsign) IN (%str(=) %str(<=) %str(=<) %str(=>) %str(>=) %str(<) %str(>))) %then '; - put ' %do; '; - put ' %put WARNING: Illegal operatopr "%superq(rVsign)"! Default(<=) will be used.; '; - put ' %put WARNING- Supported operators are: %str(= <= =< => >= < >); '; - put ' %let rVsign=<=; '; - put ' %end; '; - put ' %let rV = %sysevalf((%scan(&rV0.,1,.,M)+0)*1e8 '; - put ' + (%scan(&rV0.,2,.,M)+0)*1e4 '; - put ' + (%scan(&rV0.,3,.,M)+0)*1e0); '; - put ' '; - put ' %if NOT %sysevalf(&rV. &rVsign. &pV.) %then '; - put ' %do; '; - put ' %put ERROR: Package &packageName. will not be loaded!; '; - put ' %put ERROR- Required version is &rV0.; '; - put ' %put ERROR- Provided version is &pV0.; '; - put ' %put ERROR- Condition %bquote((&rV0. &rVsign. &pV0.)) evaluates to %sysevalf(&rV. &rVsign. &pV.); '; - put ' %put ERROR- Verify installed version of the package.; '; - put ' %put ERROR- ; '; - put ' %GOTO WrongVersionOFPackage; /*%RETURN;*/ '; - put ' %end; '; - - put ' filename &_PackageFileref_. &ZIP. '; - put ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) '; - put ' ENCODING = '; - put ' %if %bquote(&packageEncoding.) NE %then &packageEncoding. ; '; - put ' %else utf8 ; '; - put ' ; '; - - put ' %local cherryPick; %let cherryPick=*; '; - put ' %local tempLoad_minoperator; '; - put ' %let tempLoad_minoperator = %sysfunc(getoption(minoperator)); '; - put ' options minoperator; '; - - put ' %if %superq(suppressExec) NE 1 %then %let suppressExec = 0; '; - - put ' %include &_PackageFileref_.(load.sas) / &source2.; '; - put ' options &tempLoad_minoperator.; '; - - put ' filename &_PackageFileref_. clear; '; - put ' %WrongVersionOFPackage: '; - - put ' %mend ICEloadPackage; '; - put " "; + / ' %local rV pV rV0 pV0 rVsign; ' + / ' %let pV0 = %sysfunc(compress(&packageVersion.,.,kd)); ' + / ' %let pV = %sysevalf((%scan(&pV0.,1,.,M)+0)*1e8 ' + / ' + (%scan(&pV0.,2,.,M)+0)*1e4 ' + / ' + (%scan(&pV0.,3,.,M)+0)*1e0); ' + / ' ' + / ' %let rV0 = %sysfunc(compress(&requiredVersion.,.,kd)); ' + / ' %let rVsign = %sysfunc(compress(&requiredVersion.,<=>,k)); ' + / ' %if %superq(rVsign)= %then %let rVsign=<=; ' + / ' %else %if NOT (%superq(rVsign) IN (%str(=) %str(<=) %str(=<) %str(=>) %str(>=) %str(<) %str(>))) %then ' + / ' %do; ' + / ' %put WARNING: Illegal operatopr "%superq(rVsign)"! Default(<=) will be used.; ' + / ' %put WARNING- Supported operators are: %str(= <= =< => >= < >); ' + / ' %let rVsign=<=; ' + / ' %end; ' + / ' %let rV = %sysevalf((%scan(&rV0.,1,.,M)+0)*1e8 ' + / ' + (%scan(&rV0.,2,.,M)+0)*1e4 ' + / ' + (%scan(&rV0.,3,.,M)+0)*1e0); ' + / ' ' + / ' %if NOT %sysevalf(&rV. &rVsign. &pV.) %then ' + / ' %do; ' + / ' %put ERROR: Package &packageName. will not be loaded!; ' + / ' %put ERROR- Required version is &rV0.; ' + / ' %put ERROR- Provided version is &pV0.; ' + / ' %put ERROR- Condition %bquote((&rV0. &rVsign. &pV0.)) evaluates to %sysevalf(&rV. &rVsign. &pV.); ' + / ' %put ERROR- Verify installed version of the package.; ' + / ' %put ERROR- ; ' + / ' %GOTO WrongVersionOFPackage; /*%RETURN;*/ ' + / ' %end; ' + / ' filename &_PackageFileref_. &ZIP. ' + / ' "&path./%sysfunc(lowcase(&packageName.)).&zip." %unquote(&options.) ' + / ' ENCODING = ' + / ' %if %superq(packageEncoding) NE %then &packageEncoding. ; ' + / ' %else utf8 ; ' + / ' ; ' + / ' %local cherryPick; %let cherryPick=*; ' + / ' %local tempLoad_minoperator; ' + / ' %let tempLoad_minoperator = %sysfunc(getoption(minoperator)); ' + / " " + / ' %if %superq(suppressExec) NE 1 %then %let suppressExec = 0; ' + / ' %include &_PackageFileref_.(load.sas) / &source2.; ' + / ' options &tempLoad_minoperator.; ' + / ' filename &_PackageFileref_. clear; ' + / ' %WrongVersionOFPackage: ' + / ' %mend ICEloadPackage; ' + / " "; run; /* loading package files */ @@ -2715,6 +2777,7 @@ run; %put NOTE: Preparing load file.; %put NOTE- ^^^^^^^^^^^^^^^^^^^^; %put NOTE-; + data _null_; if NOBS = 0 then stop; @@ -2735,11 +2798,11 @@ data _null_; put 'data _null_; '; put ' if NOT ("*"=symget("cherryPick")) then do; '; /* Cherry Pick test0 start */ - put ' put "NOTE- "; ' / - ' put "NOTE: *** Cherry Picking ***"; ' / - ' put "NOTE- Cherry Picking in action!! Be advised that"; ' / - ' put "NOTE- dependencies/required packages will not be loaded!"; ' / - ' put "NOTE- "; ' ; + put ' put "NOTE- "; ' + / ' put "NOTE: *** Cherry Picking ***"; ' + / ' put "NOTE- Cherry Picking in action!! Be advised that"; ' + / ' put "NOTE- dependencies/required packages will not be loaded!"; ' + / ' put "NOTE- "; '; put ' end; ' ; /* Cherry Pick test0 end */ put 'run; '; @@ -2758,72 +2821,72 @@ data _null_; or (%superq(packageReqPackages) ne ) %then %do; - put ' data _null_; '; - put ' call symputX("packageRequiredErrors", 0, "L"); '; - put ' run; '; + put ' data _null_; ' + / ' call symputX("packageRequiredErrors", 0, "L"); ' + / ' run; '; %end; %if %superq(packageRequired) ne %then %do; - put ' %put NOTE- *Testing required SAS components*%sysfunc(DoSubL( '; /* <- DoSubL() is here */ - put ' options nonotes nosource %str(;) '; - put ' options ls=max ps=max locale=en_US %str(;) '; - put ' /* temporary redirect log */ '; - put ' filename _stinit_ TEMP %str(;) '; - put ' proc printto log = _stinit_ %str(;) run %str(;) '; - put ' /* print out setinit */ '; - put ' proc setinit %str(;) run %str(;) '; - put ' proc printto %str(;) run %str(;) '; + put ' %put NOTE- *Testing required SAS components*%sysfunc(DoSubL(' /* <- DoSubL() is here */ + / ' options nonotes nosource %str(;) ' + / ' options ls=max ps=max locale=en_US %str(;) ' + / ' /* temporary redirect log */ ' + / ' filename _stinit_ TEMP %str(;) ' + / ' proc printto log = _stinit_ %str(;) run %str(;) ' + / ' /* print out setinit */ ' + / ' proc setinit %str(;) run %str(;) ' + / ' proc printto %str(;) run %str(;) ' - put ' data _null_ %str(;) '; - put ' /* loadup checklist of required SAS components */ '; - put ' if _n_ = 1 then '; - put ' do %str(;) '; - put ' length req $ 256 %str(;) '; - put ' declare hash R() %str(;) '; - put ' _N_ = R.defineKey("req") %str(;) '; - put ' _N_ = R.defineDone() %str(;) '; - put ' declare hiter iR("R") %str(;) '; + / ' data _null_ %str(;) ' + / ' /* loadup checklist of required SAS components */ ' + / ' if _n_ = 1 then ' + / ' do %str(;) ' + / ' length req $ 256 %str(;) ' + / ' declare hash R() %str(;) ' + / ' _N_ = R.defineKey("req") %str(;) ' + / ' _N_ = R.defineDone() %str(;) ' + / ' declare hiter iR("R") %str(;) '; length packageRequired $ 32767; packageRequired = upcase(symget('packageRequired')); - put ' do req = %bquote(' / packageRequired / ') %str(;) '; - put ' _N_ = R.add(key:req,data:req) %str(;) '; - put ' end %str(;) '; - put ' end %str(;) '; - put ' '; - put ' /* read in output from proc setinit */ '; - put ' infile _stinit_ end=eof %str(;) '; - put ' input %str(;) '; - /*put ' put "*> " _infile_ %str(;) '; */ /* for testing */ - put ' '; - put ' /* if component is in setinit remove it from checklist */ '; - put ' if _infile_ =: "---" then '; - put ' do %str(;) '; - put ' req = upcase(substr(_infile_, 4, 64)) %str(;) '; - put ' if R.find(key:req) = 0 then '; - put ' do %str(;) '; - put ' _N_ = R.remove() %str(;) '; - put ' end %str(;) '; - put ' end %str(;) '; - put ' '; - put ' /* if checklist is not null rise error */ '; - put ' if eof and R.num_items > 0 then '; - put ' do %str(;) '; - put ' put "WARNING- ###########################################" %str(;) '; - put ' put "WARNING: The following SAS components are missing! " %str(;) '; - put ' call symputX("packageRequiredErrors", 0, "L") %str(;) '; - put ' do while(iR.next() = 0) %str(;) '; - put ' put "WARNING- " req %str(;) '; - put ' end %str(;) '; - put ' put "WARNING: The package may NOT WORK as expected " %str(;) '; - put ' put "WARNING: or even result with ERRORS! " %str(;) '; - put ' put "WARNING- ###########################################" %str(;) '; - put ' put %str(;) '; - put ' end %str(;) '; - put ' run %str(;) '; - put ' filename _stinit_ clear %str(;) '; - put ' options notes source %str(;) '; - put ' ))*; '; + put ' do req = %bquote(' / packageRequired / ') %str(;) ' + / ' _N_ = R.add(key:req,data:req) %str(;) ' + / ' end %str(;) ' + / ' end %str(;) ' + / ' ' + / ' /* read in output from proc setinit */ ' + / ' infile _stinit_ end=eof %str(;) ' + / ' input %str(;) ' + /* / ' put "*> " _infile_ %str(;) ' */ /* for testing */ + / ' ' + / ' /* if component is in setinit remove it from checklist */ ' + / ' if _infile_ =: "---" then ' + / ' do %str(;) ' + / ' req = upcase(substr(_infile_, 4, 64)) %str(;) ' + / ' if R.find(key:req) = 0 then ' + / ' do %str(;) ' + / ' _N_ = R.remove() %str(;) ' + / ' end %str(;) ' + / ' end %str(;) ' + / ' ' + / ' /* if checklist is not null rise error */ ' + / ' if eof and R.num_items > 0 then ' + / ' do %str(;) ' + / ' put "WARNING- ###########################################" %str(;) ' + / ' put "WARNING: The following SAS components are missing! " %str(;) ' + / ' call symputX("packageRequiredErrors", 0, "L") %str(;) ' + / ' do while(iR.next() = 0) %str(;) ' + / ' put "WARNING- " req %str(;) ' + / ' end %str(;) ' + / ' put "WARNING: The package may NOT WORK as expected " %str(;) ' + / ' put "WARNING: or even result with ERRORS! " %str(;) ' + / ' put "WARNING- ###########################################" %str(;) ' + / ' put %str(;) ' + / ' end %str(;) ' + / ' run %str(;) ' + / ' filename _stinit_ clear %str(;) ' + / ' options notes source %str(;) ' + / ' ))*; '; %end; %if %superq(packageReqPackages) ne %then @@ -2833,146 +2896,145 @@ data _null_; packageReqPackages = lowcase(symget('packageReqPackages')); /* try to load required packages */ - put 'data _null_ ; '; - put ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages loading."; stop; end; '; - put ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' end; '; - put ' SYSloadedPackages = lowcase(SYSloadedPackages); '; + put 'data _null_ ; ' + / ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages loading."; stop; end; ' + / ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' end; ' + / ' SYSloadedPackages = lowcase(SYSloadedPackages); ' - put ' declare hash LP(); '; - put ' LP.defineKey("name"); '; - put ' LP.defineData("vers"); '; - put ' LP.defineDone(); '; - put ' do _N_ = 1 to countw(SYSloadedPackages); '; - put ' req = kscanx(SYSloadedPackages, _N_, " "); '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' _RC_ = LP.add(); '; - put ' end; '; + / ' declare hash LP(); ' + / ' LP.defineKey("name"); ' + / ' LP.defineData("vers"); ' + / ' LP.defineDone(); ' + / ' do _N_ = 1 to countw(SYSloadedPackages); ' + / ' req = kscanx(SYSloadedPackages, _N_, " "); ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' _RC_ = LP.add(); ' + / ' end; ' /* check if elements of the framework are available */ - put ' LoadPackageExist = input(resolve(''%SYSMACEXIST( loadPackage)''), best.); '; - put ' ICELoadPackageExist = input(resolve(''%SYSMACEXIST(ICEloadPackage)''), best.); '; + / ' LoadPackageExist = input(resolve(''%SYSMACEXIST( loadPackage)''), best.); ' + / ' ICELoadPackageExist = input(resolve(''%SYSMACEXIST(ICEloadPackage)''), best.); ' - put ' do req = ' / packageReqPackages / ' ; '; -/* put ' req = compress(req, "(.)", "KDF"); ';*/ - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = ""; '; - put ' LP_find = LP.find(); '; + / ' do req = ' / packageReqPackages / ' ; ' +/* / ' req = compress(req, "(.)", "KDF"); '*/ + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = ""; ' + / ' LP_find = LP.find(); ' /* convert major.minor.patch to number*/ - put ' array V verR vers ; '; - put ' array VN verRN versN; '; - put ' do over V; '; - put ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 '; - put ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 '; - put ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; '; - put ' end; '; + / ' array V verR vers ; ' + / ' array VN verRN versN; ' + / ' do over V; ' + / ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 ' + / ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 ' + / ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; ' + / ' end; ' - put ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then '; - put ' do; '; - put ' put "NOTE: Trying to load required SAS package: " req; '; - put ' if LoadPackageExist then '; - put ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); '; - put ' else if ICELoadPackageExist then '; - put ' call execute(cats(''%nrstr(%ICEloadPackage('', name, ", requiredVersion = ", verR, "))")); '; - put ' end ; '; - put ' end ; '; - put ' stop; '; - put 'run; '; + / ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then ' + / ' do; ' + / ' put "NOTE: Trying to load required SAS package: " req; ' + / ' if LoadPackageExist then ' + / ' call execute(cats(''%nrstr(%loadPackage('', name, ", requiredVersion = ", verR, "))")); ' + / ' else if ICELoadPackageExist then ' + / ' call execute(cats(''%nrstr(%ICEloadPackage('', name, ", requiredVersion = ", verR, "))")); ' + / ' end ; ' + / ' end ; ' + / ' stop; ' + / 'run; ' /* test if required packages are loaded */ - put 'data _null_ ; '; - put ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages checking."; stop; end; '; - put ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = lowcase(SYSloadedPackages); '; + / 'data _null_ ; ' + / ' if "*" NE symget("cherryPick") then do; put "NOTE: No required packages checking."; stop; end; ' + / ' length req name $ 64 vers verR $ 24 versN verRN 8 SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = lowcase(SYSloadedPackages); ' - put ' declare hash LP(); '; - put ' LP.defineKey("name"); '; - put ' LP.defineData("vers"); '; - put ' LP.defineDone(); '; - put ' do _N_ = 1 to countw(SYSloadedPackages); '; - put ' req = kscanx(SYSloadedPackages, _N_, " "); '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' _RC_ = LP.add(); '; - put ' end; '; + / ' declare hash LP(); ' + / ' LP.defineKey("name"); ' + / ' LP.defineData("vers"); ' + / ' LP.defineDone(); ' + / ' do _N_ = 1 to countw(SYSloadedPackages); ' + / ' req = kscanx(SYSloadedPackages, _N_, " "); ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' _RC_ = LP.add(); ' + / ' end; ' - put ' missingPackagr = 0; '; - put ' do req = ' / packageReqPackages / ' ; '; -/* put ' req = compress(req, "(.)", "KDF"); ';*/ - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = " "; '; - put ' LP_find = LP.find(); '; + / ' missingPackagr = 0; ' + / ' do req = ' / packageReqPackages / ' ; ' +/* / ' req = compress(req, "(.)", "KDF"); '*/ + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' verR = compress(kscanx(req,-1, "("), ".", "KD"); vers = " "; ' + / ' LP_find = LP.find(); ' /* convert major.minor.patch to number*/ - put ' array V verR vers ; '; - put ' array VN verRN versN; '; - put ' do over V; '; - put ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 '; - put ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 '; - put ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; '; - put ' end; '; - - put ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then '; - put ' do; '; - put ' missingPackagr = 1; '; - put ' put "ERROR: SAS package: " req "is missing! Download it by hand or if the SAS session";'; - put ' put "ERROR- has access to the Internet and the package is available at SASPAC repository";'; - put ' put ''ERROR- use %installPackage('' name +(-1) "(" verR +(-1) ")) to install it."/; '; - put ' put ''ERROR- Use %loadPackage('' name +(-1) ", requiredVersion=" verR +(-1) ") to load it."/;'; - put ' end ; '; - put ' end ; '; - put ' if missingPackagr then call symputX("packageRequiredErrors", 1, "L"); '; - put ' end; '; - put ' else '; - put ' do; '; - put ' put "ERROR: No package loaded!"; '; - put ' call symputX("packageRequiredErrors", 1, "L"); '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' name = lowcase(strip(kscanx(req, 1, "("))); '; - put ' vers = compress(kscanx(req,-1, "("), ".", "KD"); '; - put ' put "ERROR: SAS package " req "is missing! Download it by hand or if the SAS session";'; - put ' put "ERROR- has access to the Internet and the package is available at SASPAC repository";'; - put ' put ''ERROR- use %installPackage('' name +(-1) "(" vers +(-1) ")) to install it."/; '; - put ' put ''ERROR- Use %loadPackage('' name +(-1)", requiredVersion=" vers +(-1) ") to load it."/;'; - put ' end ; '; - put ' end; '; - put ' stop; '; - put 'run; '; + / ' array V verR vers ; ' + / ' array VN verRN versN; ' + / ' do over V; ' + / ' VN = input("0"!!scan(V,1,".","M"),?? best.)*1e8 ' + / ' + input("0"!!scan(V,2,".","M"),?? best.)*1e4 ' + / ' + input("0"!!scan(V,3,".","M"),?? best.)*1e0; ' + / ' end; ' + / ' if (LP_find ne 0) or (LP_find = 0 and . < versN < verRN) then ' + / ' do; ' + / ' missingPackagr = 1; ' + / ' put "ERROR: SAS package: " req "is missing! Download it by hand or if the SAS session"; ' + / ' put "ERROR- has access to the Internet and the package is available at SASPAC repository"; ' + / ' put ''ERROR- use %installPackage('' name +(-1) "(" verR +(-1) ")) to install it."/; ' + / ' put ''ERROR- Use %loadPackage('' name +(-1) ", requiredVersion=" verR +(-1) ") to load it."/; ' + / ' end ; ' + / ' end ; ' + / ' if missingPackagr then call symputX("packageRequiredErrors", 1, "L"); ' + / ' end; ' + / ' else ' + / ' do; ' + / ' put "ERROR: No package loaded!"; ' + / ' call symputX("packageRequiredErrors", 1, "L"); ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' name = lowcase(strip(kscanx(req, 1, "("))); ' + / ' vers = compress(kscanx(req,-1, "("), ".", "KD"); ' + / ' put "ERROR: SAS package " req "is missing! Download it by hand or if the SAS session"; ' + / ' put "ERROR- has access to the Internet and the package is available at SASPAC repository"; ' + / ' put ''ERROR- use %installPackage('' name +(-1) "(" vers +(-1) ")) to install it."/; ' + / ' put ''ERROR- Use %loadPackage('' name +(-1)", requiredVersion=" vers +(-1) ") to load it."/; ' + / ' end ; ' + / ' end; ' + / ' stop; ' + / 'run; '; %end; %if (%superq(packageRequired) ne ) or (%superq(packageReqPackages) ne ) %then %do; - put ' data _null_; '; - put ' if 1 = symgetn("packageRequiredErrors") then '; - put ' do; '; - put ' put "ERROR: Loading package &packageName. will be aborted!";'; - put ' put "ERROR- Required components are missing."; '; - put ' put "ERROR- *** STOP ***"; '; - put ' call symputX("packageRequiredErrors",'; - put ' ''options ls = &ls_tmp. ps = &ps_tmp. '; - put ' ¬es_tmp. &source_tmp. msglevel=&msglevel_tmp. '; - put ' &stimer_tmp. &fullstimer_tmp. ;'; - put ' data _null_;abort;run;'', "L"); '; - put ' end; '; - put ' else '; - put ' call symputX("packageRequiredErrors", " ", "L");'; - put ' run; '; - put ' &packageRequiredErrors. '; + put ' data _null_; ' + / ' if 1 = symgetn("packageRequiredErrors") then ' + / ' do; ' + / ' put "ERROR: Loading package &packageName. will be aborted!";' + / ' put "ERROR- Required components are missing."; ' + / ' put "ERROR- *** STOP ***"; ' + / ' call symputX("packageRequiredErrors",' + / ' ''options ls = &ls_tmp. ps = &ps_tmp. ' + / ' ¬es_tmp. &source_tmp. msglevel=&msglevel_tmp. ' + / ' &stimer_tmp. &fullstimer_tmp. ;' + / ' data _null_;abort;run;'', "L"); ' + / ' end; ' + / ' else ' + / ' call symputX("packageRequiredErrors", " ", "L");' + / ' run; ' + / ' &packageRequiredErrors. '; %end; @@ -3011,9 +3073,9 @@ data _null_; if 1 = isFunction and upcase(type)=:'FUNCTION' then do; /* macro variable for test if cherry picking used FCMP */ - put 'data _null_; '; - put " call symputX('cherryPick_FCMP', exist('work.&packageName.fcmp'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_FCMP', exist('work.&packageName.fcmp'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='FUNCTIONS' then do; @@ -3023,9 +3085,9 @@ data _null_; if 1 = isProto and upcase(type)='PROTO' then do; /* macro variable for test if cherry picking used PROTO */ - put 'data _null_; '; - put " call symputX('cherryPick_PROTO', exist('work.&packageName.proto'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_PROTO', exist('work.&packageName.proto'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='PROTO' then do; @@ -3034,15 +3096,15 @@ data _null_; value of "package=" overwrites previously created content */ /* header for multiple functions in one PROTO run */ - put "proc proto package = work.&packageName.proto.package" ProtoGrpNum / - " LABEL='Proc Proto C functions for &packageName. package, part" ProtoGrpNum "' ; "; + put "proc proto package = work.&packageName.proto.package" ProtoGrpNum + / " LABEL='Proc Proto C functions for &packageName. package, part" ProtoGrpNum "' ; "; end; if 1 = isFormat and upcase(type)=:'FORMAT' then do; /* macro variable for test if cherry picking used FORMAT */ - put 'data _null_; '; - put " call symputX('cherryPick_FORMAT', cexist('work.&packageName.format'), 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_FORMAT', cexist('work.&packageName.format'), 'L'); " + / 'run; '; end; if 1 = FIRST.type and upcase(type)='FORMATS' then do; @@ -3052,25 +3114,25 @@ data _null_; if 1 = isIMLmodule and upcase(type)='IMLMODULE' then do; /* macro variable for test if cherry picking used IML */ - put 'data _null_; '; - put ' call symputX("cherryPick_IML_ALL", 0, "L"); '; - put 'run; '; + put 'data _null_; ' + / ' call symputX("cherryPick_IML_ALL", 0, "L"); ' + / 'run; '; end; if 1 = FIRST.type and upcase(type)='IMLMODULE' then do; /* macro variable for test if cherry picking used IML */ - put 'data _null_; '; - put ' call symputX("cherryPick_IML", 0, "L"); '; - put 'run; '; + put 'data _null_; ' + / ' call symputX("cherryPick_IML", 0, "L"); ' + / 'run; '; /* header, for IML modules */ put "proc iml ; "; end; /* HEADERS for PROC IML, FCMP, and PROTO - end */ - put ' ' / - '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; '; /* Cherry Pick test1 start */ - put ' %put NOTE- ;'; - put ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; + put ' ' + / '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; ' /* Cherry Pick test1 start */ + / ' %put NOTE- ;' + / ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; if upcase(type)=:'MACRO' then put ' %put %sysfunc(ifc(%SYSMACEXIST(' fileshort +(-1) ')=1, NOTE# Macro ' fileshort @@ -3106,16 +3168,16 @@ data _null_; if 1 = isDS2pck and upcase(type)=:'DS2PCK' then do; /* macro variable for test if cherry picking used DS2 package */ - put 'data _null_; '; - put " call symputX('cherryPick_DS2PCK', 0, 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_DS2PCK', 0, 'L'); " + / 'run; '; end; if 1 = isDS2thr and upcase(type)=:'DS2THR' then do; /* macro variable for test if cherry picking used DS2 threads */ - put 'data _null_; '; - put " call symputX('cherryPick_DS2THR', 0, 'L'); "; - put 'run; '; + put 'data _null_; ' + / " call symputX('cherryPick_DS2THR', 0, 'L'); " + / 'run; '; end; @@ -3209,12 +3271,12 @@ data _null_; end; if 1 = LAST.type and upcase(type)='IMLMODULE' then /* footer, for IML modules */ do; - put '%if 0 < &cherryPick_IML. %then %do; ' / - '%let cherryPick_IML_ALL = %eval(&cherryPick_IML_ALL. + &cherryPick_IML.);' / - "reset storage = WORK.&packageName.IML; " / /* set the storage location for modules */ - "store module = _ALL_; " / /* and store all created modules */ - '%end; ' / - "quit; " / ; + put '%if 0 < &cherryPick_IML. %then %do; ' + / '%let cherryPick_IML_ALL = %eval(&cherryPick_IML_ALL. + &cherryPick_IML.);' + / "reset storage = WORK.&packageName.IML; " /* set the storage location for modules */ + / "store module = _ALL_; " /* and store all created modules */ + / '%end; ' + / "quit; " ; end; /* FOOTERS for PROC IML, FCMP, and PROTO - end */ @@ -3225,11 +3287,11 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'FUNCTION') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' / - " ,work.%sysfunc(lowcase(&packageName.fcmp)),""'( )'"",RIO))" / - ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.fcmp)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' + / " ,work.%sysfunc(lowcase(&packageName.fcmp)),""'( )'"",RIO))" + / ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.fcmp)));)" + / '))' ; end; /* add the link to the proto functions dataset, only for the first occurrence */ @@ -3239,11 +3301,11 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'PROTO') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' / - " ,work.%sysfunc(lowcase(&packageName.proto)),""'( )'"",RIO))" / - ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.proto)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(cmplib)))' + / " ,work.%sysfunc(lowcase(&packageName.proto)),""'( )'"",RIO))" + / ',,%str(options' " APPEND=(cmplib = work.%sysfunc(lowcase(&packageName.proto)));)" + / '))' ; end; /* add the link to the formats catalog, only for the first occurrence */ @@ -3253,76 +3315,76 @@ data _null_; end;*/ if 1 = FIRST.type and (upcase(type)=:'FORMAT') then do; - put '%sysfunc(ifc(0<' / - ' %sysfunc(findw((%sysfunc(getoption(fmtsearch)))' / - " ,work.%sysfunc(lowcase(&packageName.format)),""'( )'"",RIO))" / - ',,%str(options' " INSERT=(fmtsearch = work.%sysfunc(lowcase(&packageName.format)));)" / - '))' ; + put '%sysfunc(ifc(0<' + / ' %sysfunc(findw((%sysfunc(getoption(fmtsearch)))' + / " ,work.%sysfunc(lowcase(&packageName.format)),""'( )'"",RIO))" + / ',,%str(options' " INSERT=(fmtsearch = work.%sysfunc(lowcase(&packageName.format)));)" + / '))'; end; end; /* loopOverTypes - start */ /* this is a header for CASLudf macro */ - put 'data _null_; '; - put ' call symputX("cherryPick_CASLUDF", 0, "L"); '; - put 'run; '; - put 'data _null_;'; - put 'length CASLUDF $ 32767;'; - put 'dtCASLudf = datetime();'; - put 'CASLUDF = '; - put ' ''%macro ' "&packageName.CASLudf(' "; - put ' !! "list=1,depList=" '; - %if %superq(packageReqPackages) ne %then - %do; - length reqPackage $ 32; - do i = 1 to countw(packageReqPackages, ",", "Q"); - reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; - put ' !! " ' reqPackage ' " '; - end; - %end; + put 'data _null_; ' + / ' call symputX("cherryPick_CASLUDF", 0, "L"); ' + / 'run; ' + / 'data _null_; ' + / 'length CASLUDF $ 32767; ' + / 'dtCASLudf = datetime(); ' + / 'CASLUDF = ' + / ' ''%macro ' "&packageName.CASLudf(' " + / ' !! "list=1,depList=" '; + + %if %superq(packageReqPackages) ne %then + %do; + length reqPackage $ 32; + do i = 1 to countw(packageReqPackages, ",", "Q"); + reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; + put ' !! " ' reqPackage ' " '; + end; + %end; put " !! ')/ des = ''CASL User Defined Functions loader for &packageName. package'';'"; - put ' !! '' %if HELP = %superq(list) %then ''' / - ' !! '' %do; ''' / - ' !! '' %put ****************************************************************************;''' / - ' !! '' %put This is help for the `' "&packageName.CASLudf" '` macro;''' / - ' !! '' %put Parameters (optional) are the following:;''' / + put ' !! '' %if HELP = %superq(list) %then ''' + / ' !! '' %do; ''' + / ' !! '' %put ****************************************************************************;''' + / ' !! '' %put This is help for the `' "&packageName.CASLudf" '` macro;''' + / ' !! '' %put Parameters (optional) are the following:;''' - ' !! '' %put - `list` indicates if the list of loaded CASL UDFs should be displayed,;''' / - ' !! '' %put %str( )when set to the value of `1` (the default) runs `FUNCTIONLIST USER%str(;)`,;''' / - ' !! '' %put %str( )when set to the value of `HELP` (upcase letters!) displays this help message.;''' / + / ' !! '' %put - `list` indicates if the list of loaded CASL UDFs should be displayed,;''' + / ' !! '' %put %str( )when set to the value of `1` (the default) runs `FUNCTIONLIST USER%str(;)`,;''' + / ' !! '' %put %str( )when set to the value of `HELP` (upcase letters!) displays this help message.;''' - ' !! '' %put - `depList` [technical] contains the list of dependencies required by the package.;''' / - ' !! '' %put %str( )for _this_ instance of the macro the default value is: `' @; - %if %superq(packageReqPackages) ne %then - %do; - do i = 1 to countw(packageReqPackages, ",", "Q"); - reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; - put reqPackage @; - end; - %end; - put +(-1) '`.;''' / - ' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' / - ' !! '' %put with the SAS Packages Framework version 20251221.;''' / - ' !! '' %put ****************************************************************************;''' / - ' !! '' %GOTO theEndOfTheMacro;''' / - ' !! '' %end;''' ; + / ' !! '' %put - `depList` [technical] contains the list of dependencies required by the package.;''' + / ' !! '' %put %str( )for _this_ instance of the macro the default value is: `' @; + %if %superq(packageReqPackages) ne %then + %do; + do i = 1 to countw(packageReqPackages, ",", "Q"); + reqPackage = compress(scan(scan(packageReqPackages, i, ",", "Q"), 1, "[{( )}]"),"_","KAD") ; + put reqPackage @; + end; + %end; + put +(-1) '`.;''' + / ' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' + / ' !! '' %put with the SAS Packages Framework version 20251231.;''' + / ' !! '' %put ****************************************************************************;''' + / ' !! '' %GOTO theEndOfTheMacro;''' + / ' !! '' %end;''' ; + put ' !! '' %if %superq(depList) ne %then ''' + / ' !! '' %do; ''' + / ' !! '' %do i = 1 %to %sysfunc(countw(&depList.,%str( ))); ''' + / ' !! '' %let depListNm = %scan(&depList.,&i.,%str( )); ''' + / ' !! '' %if %SYSMACEXIST(&depListNm.CASLudf) %then ''' + / ' !! '' %do; ''' + / ' !! '' %&depListNm.CASLudf(list=0) ''' + / ' !! '' %end; ''' + / ' !! '' %end; ''' + / ' !! '' %end; ''' - put ' !! '' %if %superq(depList) ne %then ''' / - ' !! '' %do; ''' / - ' !! '' %do i = 1 %to %sysfunc(countw(&depList.,%str( ))); ''' / - ' !! '' %let depListNm = %scan(&depList.,&i.,%str( )); ''' / - ' !! '' %if %SYSMACEXIST(&depListNm.CASLudf) %then ''' / - ' !! '' %do; ''' / - ' !! '' %&depListNm.CASLudf(list=0) ''' / - ' !! '' %end; ''' / - ' !! '' %end; ''' / - ' !! '' %end; ''' ; - - put ' !! '' %local tmp_NOTES;'' '; - put ' !! '' %let tmp_NOTES = %sysfunc(getoption(NOTES));'' '; + / ' !! '' %local tmp_NOTES;'' ' + / ' !! '' %let tmp_NOTES = %sysfunc(getoption(NOTES));''' ; /* the PATH macrovariable will be resolved when the load.sas file is executed */ put ' !! " filename ' "&_PackageFileref_." ' &ZIP. ''&path./' "%sysfunc(lowcase(&packageName.))" '.&zip.'';"'; @@ -3333,94 +3395,94 @@ data _null_; if not (upcase(type) = 'CASLUDF') then continue; /* only CASLUDF type in this loop */ isCASLudf + 1; - put ' ' / - '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; '; /* Cherry Pick test2 start */ - put ' %put NOTE- ;'; - put ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;'; + put ' ' + / '%if (%str(*)=%superq(cherryPick)) or (' fileshort +(-1) ' in %superq(cherryPick)) %then %do; ' /* Cherry Pick test2 start */ + / ' %put NOTE- ;' + / ' %put NOTE: >> Element of type ' type 'from the file "' file +(-1) '" will be included <<;' /* for CASLUDF we are building code of a macro to be run while loading */ - put ' !! '' %include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;'''; - put ' %let cherryPick_CASLUDF = %eval(&cherryPick_CASLUDF. + 1);'; - put '%end; ' /; /* Cherry Pick test2 end */ + / ' !! '' %include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;''' + / ' %let cherryPick_CASLUDF = %eval(&cherryPick_CASLUDF. + 1);' + / '%end; ' / ; /* Cherry Pick test2 end */ end; /* loopOverTypes1 - end */ /* this is a footer for CASLudf macro */ - put ' !! " options nonotes;" ' / - " !! ' filename &_PackageFileref_. clear;' " / - ' !! '' options &tmp_NOTES.;'' ' / - ' !! '' %if 1 = %superq(list) %then '' ' / - ' !! '' %do; '' ' / - ' !! " FUNCTIONLIST USER;" ' / - ' !! " run;" ' / - ' !! '' %end; '' ' ; - put ' !! ''%theEndOfTheMacro: %mend;''; ' ; + put ' !! " options nonotes;" ' + / " !! ' filename &_PackageFileref_. clear;' " + / ' !! '' options &tmp_NOTES.;'' ' + / ' !! '' %if 1 = %superq(list) %then '' ' + / ' !! '' %do; '' ' + / ' !! " FUNCTIONLIST USER;" ' + / ' !! " run;" ' + / ' !! '' %end; '' ' + / ' !! ''%theEndOfTheMacro: %mend;''; ' ; /* generate macro for CASL user defined functions */ if 0 < isCASLudf then do; - put '%if 0 < &cherryPick_CASLUDF. %then %do; '; - /*put ' put / / CASLUDF / / ; ';*/ - put " rc = resolve(CASLUDF); "; - put ' put "NOTE: Macro named:"; '; - put " put @7 '%' '&packageName.CASLudf()'; "; - put ' put "NOTE- will be generated. Its purpose";'; - put ' put "NOTE- is to allow fast load of CASL"; '; - put ' put "NOTE- user defined functions into"; '; - put ' put "NOTE- the Proc CAS session."; '; - put ' put "NOTE-"; '; - put ' put "NOTE- Use it the following way:"; '; - put " put @7 'Proc CAS;'; "; - put " put @7 ' %' '&packageName.CASLudf()'; "; - put " put @7 ' <... your code ...>'; "; - put " put @7 'quit;'; "; - put ' put "NOTE-"; '; - put ' put "NOTE-To get help run:"; '; - put " put @7 ' %' '&packageName.CASLudf(list=HELP)';"; - put ' put "NOTE-"; '; - put '%end; '; + put '%if 0 < &cherryPick_CASLUDF. %then %do; ' + /* / ' put / / CASLUDF / / ; '*/ + / " rc = resolve(CASLUDF); " + / ' put "NOTE: Macro named:"; ' + / " put @7 '%' '&packageName.CASLudf()'; " + / ' put "NOTE- will be generated. Its purpose";' + / ' put "NOTE- is to allow fast load of CASL"; ' + / ' put "NOTE- user defined functions into"; ' + / ' put "NOTE- the Proc CAS session."; ' + / ' put "NOTE-"; ' + / ' put "NOTE- Use it the following way:"; ' + / " put @7 'Proc CAS;'; " + / " put @7 ' %' '&packageName.CASLudf()'; " + / " put @7 ' <... your code ...>'; " + / " put @7 'quit;'; " + / ' put "NOTE-"; ' + / ' put "NOTE-To get help run:"; ' + / " put @7 ' %' '&packageName.CASLudf(list=HELP)';" + / ' put "NOTE-"; ' + / '%end; '; end; put 'run;'/; /* cherry pick clean in cmplib for functions */ if isFunction then do; - put '%if 0 = &cherryPick_FCMP. %then %do;'; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%end;'; + put '%if 0 = &cherryPick_FCMP. %then %do;' + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%end;'; end; /* cherry pick clean in cmplib for proto */ if isProto then do; - put '%if 0 = &cherryPick_PROTO. %then %do;'; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; + put '%if 0 = &cherryPick_PROTO. %then %do;' + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));'; /* proc delete is adde because "empty" PROTO creates dataset too */ - put "proc delete data=work.&packageName.proto; run;"; - put '%end;'; + put "proc delete data=work.&packageName.proto; run;" + / '%end;'; end; /* list fmtsearch for formats */ if isFormat then do; - put '%if 0 = &cherryPick_FORMAT. %then %do;'; - put 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));'; - put 'options fmtsearch = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(fmtsearch))' / - ', %str(()) ))));'; - put '%end;'; - put '%put NOTE- ;'; + put '%if 0 = &cherryPick_FORMAT. %then %do;' + / 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));' + / 'options fmtsearch = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(fmtsearch))' + / ', %str(()) ))));' + / '%end;' + / '%put NOTE- ;'; end; /* create a macro loader for IML modules with dependencies */ @@ -3468,16 +3530,16 @@ data _null_; end; %end; put +(-1) '`.; '' !!' / - ''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !!' / - ''' %put with the SAS Packages Framework version 20251221.; '' !! ' / - ''' %put ****************************************************************************; '' !! ' / + ''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !! ' / + ''' %put with the SAS Packages Framework version 20251231.; '' !! ' / + ''' %put ****************************************************************************; '' !! ' / ''' %GOTO theEndOfTheMacro; '' !! ' / ''' %end; '' !! ' / ''' %local localSYSmacroName localPackageName i depListNm; '' !! ' / ''' %let localSYSmacroName = &sysmacroname.; '' !! ' / ''' %let localSYSmacroName = %sysfunc(lowcase(&localSYSmacroName.)); '' !! ' / - ''' %let localPackageName = %substr(&localSYSmacroName.,1,%eval(%length(&localSYSmacroName.)-3));'' !!' / + ''' %let localPackageName = %substr(&localSYSmacroName.,1,%eval(%length(&localSYSmacroName.)-3));'' !! ' / ''' %if %superq(depList) ne %then '' !!' / ''' %do; '' !!' / @@ -3512,22 +3574,22 @@ data _null_; put "; rc = resolve(IML); run;"; /* wrapper end */ - put '%put NOTE: Macro named:; '; - put '%put %nrstr( %%)' "&packageName." 'IML(); '; - put '%put NOTE- will be generated. Its purpose; '; - put '%put NOTE- is to allow fast load of IML; '; - put '%put NOTE- user defined modules into; '; - put '%put NOTE- the Proc IML session.; '; - put '%put NOTE-; '; - put '%put NOTE- Use it the following way:; '; - put '%put %nrstr( )Proc IML%str(;); '; - put '%put %nrstr( %%)' "&packageName." 'IML(); '; - put '%put %nrstr( )<... your code ...>; '; - put '%put %nrstr( )quit%str(;); '; - put '%put NOTE- ; '; - put '%put NOTE- To get help info run:; '; - put '%put %nrstr( %%)' "&packageName." 'IML(list=HELP);'; - put '%put NOTE-; '; + put '%put NOTE: Macro named:; ' + / '%put %nrstr( %%)' "&packageName." 'IML(); ' + / '%put NOTE- will be generated. Its purpose; ' + / '%put NOTE- is to allow fast load of IML; ' + / '%put NOTE- user defined modules into; ' + / '%put NOTE- the Proc IML session.; ' + / '%put NOTE-; ' + / '%put NOTE- Use it the following way:; ' + / '%put %nrstr( )Proc IML%str(;); ' + / '%put %nrstr( %%)' "&packageName." 'IML(); ' + / '%put %nrstr( )<... your code ...>; ' + / '%put %nrstr( )quit%str(;); ' + / '%put NOTE- ; ' + / '%put NOTE- To get help info run:; ' + / '%put %nrstr( %%)' "&packageName." 'IML(list=HELP);' + / '%put NOTE-; '; put '%end;'; end; @@ -3694,53 +3756,53 @@ data _null_; if isFormat then do; put '%put NOTE- ;'; - put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));'/; + put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /; end; /* update SYSloadedPackages global macrovariable */ - put 'options noNotes;'; - put '%if (%str(*)=%superq(cherryPick)) %then %do; '; /* Cherry Pick test3 start */ - put ' data _null_ ; '; - put ' length SYSloadedPackages stringPCKG $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); '; + put 'options noNotes;' + / '%if (%str(*)=%superq(cherryPick)) %then %do; ' /* Cherry Pick test3 start */ + / ' data _null_ ; ' + / ' length SYSloadedPackages stringPCKG $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); ' - put " indexPCKG = INDEX(lowcase(SYSloadedPackages), '#%sysfunc(lowcase(&packageName.))('); "; - put " if indexPCKG = 0 then "; - put ' do; '; - put " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; '; - put ' end ; '; - put " else "; - put ' do; '; - put " stringPCKG = kscanx(substr(SYSloadedPackages, indexPCKG+1), 1, '#'); "; - put ' SYSloadedPackages = compbl(tranwrd(SYSloadedPackages, strip(stringPCKG), "#")); '; - put " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; '; - put ' end ; '; - put ' end; '; - put ' else '; - put ' do; '; - put " call symputX('SYSloadedPackages', '&packageName.(&packageVersion.)', 'G'); "; - put " put / 'INFO:[SYSLOADEDPACKAGES] &packageName.(&packageVersion.)'; "; - put ' end; '; - put ' stop; '; - put ' run; '; - put '%end; ' / ; /* Cherry Pick test3 end */ + / " indexPCKG = INDEX(lowcase(SYSloadedPackages), '#%sysfunc(lowcase(&packageName.))('); " + / " if indexPCKG = 0 then " + / ' do; ' + / " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; ' + / ' end ; ' + / " else " + / ' do; ' + / " stringPCKG = kscanx(substr(SYSloadedPackages, indexPCKG+1), 1, '#'); " + / ' SYSloadedPackages = compbl(tranwrd(SYSloadedPackages, strip(stringPCKG), "#")); ' + / " SYSloadedPackages = catx('#', SYSloadedPackages, '&packageName.(&packageVersion.)'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put / "INFO:[SYSLOADEDPACKAGES] " SYSloadedPackages ; ' + / ' end ; ' + / ' end; ' + / ' else ' + / ' do; ' + / " call symputX('SYSloadedPackages', '&packageName.(&packageVersion.)', 'G'); " + / " put / 'INFO:[SYSLOADEDPACKAGES] &packageName.(&packageVersion.)'; " + / ' end; ' + / ' stop; ' + / ' run; ' + / '%end; ' / ; /* Cherry Pick test3 end */ - put 'options NOTES;'; - put '%put NOTE- ;'; - put '%put NOTE: '"Loading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; + put 'options NOTES;' + / '%put NOTE- ;' + / '%put NOTE: '"Loading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' /; put 'options &temp_noNotes_etc.;' / '%symdel temp_noNotes_etc / noWarn;'; @@ -3759,9 +3821,9 @@ data _null_; file &zipReferrence.(lazydata.sas) lrecl=32767 encoding = &packageEncoding.; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: ' @; put "Data for package &packageName., version &packageVersion., license &packageLicense.; "; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: ' @; put "Data for package &packageName., version &packageVersion., license &packageLicense.; "; put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; @@ -3774,42 +3836,42 @@ data _null_; /*put '%include ' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /;*/ /* <- copied also to loadPackage macro */ - put 'data _null_;'; - put ' length lazyData $ 32767; lazyData = lowcase(symget("lazyData"));'; + put 'data _null_;' + / ' length lazyData $ 32767; lazyData = lowcase(symget("lazyData"));'; do until(eof); set &filesWithCodes. end = EOF nobs=NOBS; if ( upcase(type) =: 'LAZYDATA' ) then do; - put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then'; - put 'do;'; - put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";'; - put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');'; - put 'end;' /; + put 'if lazyData="*" OR findw(lazyData, "' fileshort +(-1) '") then' + / 'do;' + / ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";' + / ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');' + / 'end;' ; end; /* use lazyData to reload data type */ if ( upcase(type) =: 'DATA' ) then do; - put 'if findw(lazyData, "' fileshort +(-1) '") then'; - put 'do;'; - put ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";'; - put ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');'; - put 'end;' /; + put 'if findw(lazyData, "' fileshort +(-1) '") then' + / 'do;' + / ' put "NOTE- Dataset ' fileshort 'from the file ""' file +(-1) '"" will be loaded";' + / ' call execute(''%nrstr(%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;)'');' + / 'end;' ; end; end; put 'run;'; - put '%put NOTE- ;'; - put '%put NOTE: '"Data for package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* lazydata.sas end */" /; + put '%put NOTE- ;' + / '%put NOTE: '"Data for package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* lazydata.sas end */" ; stop; run; /* unloading package objects */ -%put NOTE-; +%put NOTE-; %put NOTE: Preparing unload file.; %put NOTE- ^^^^^^^^^^^^^^^^^^^^^^; %put NOTE-; @@ -3819,102 +3881,100 @@ data _null_; file &zipReferrence.(unload.sas) encoding = &packageEncoding.; - put "filename &_PackageFileref_. list;" /; - put '%put NOTE: '"Unloading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** START ***;' /; + put "filename &_PackageFileref_. list;" + / '%put NOTE: '"Unloading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** START ***;'; /* include "cleaning" files */ EOF = 0; do until(EOF); set &filesWithCodes. end = EOF nobs = NOBS; if not (upcase(type)=:'CLEAN') then continue; - put '%put NOTE- Code of type ' type 'generated from the file "' file +(-1) '" will be executed;'; - put '%put NOTE- ;' /; - put '%put NOTE- Executing the following code: ;'; - put '%put NOTE- *****************************;'; - put 'data _null_;'; - put " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;'; - put ' input;'; - put ' putlog "*> " _infile_;'; - put 'run;' /; - put '%put NOTE- *****************************;'; - put '%put NOTE- ;'; + put '%put NOTE- Code of type ' type 'generated from the file "' file +(-1) '" will be executed;' + / '%put NOTE- ;' + / '%put NOTE- Executing the following code: ;' + / '%put NOTE- *****************************;' + / 'data _null_;' + / " infile &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') lrecl=32767;' + / ' input;' + / ' putlog "*> " _infile_;' + / 'run;' + / '%put NOTE- *****************************;' + / '%put NOTE- ;'; put '%include' " &_PackageFileref_.(_" folder +(-1) "." file +(-1) ') / nosource2;' /; end; /* delete macros and formats */ - put 'proc sql;'; - put ' create table WORK._%sysfunc(datetime(), hex16.)_ as'; - put ' select memname, objname, objtype'; - put ' from dictionary.catalogs'; - put ' where '; - put ' ('; - put ' objname in ("*"' ; - put " ,%UPCASE('&packageName.IML')" ; - put " ,%UPCASE('&packageName.CASLUDF')" /; + put 'proc sql;' + / ' create table WORK._%sysfunc(datetime(), hex16.)_ as' + / ' select memname, objname, objtype' + / ' from dictionary.catalogs' + / ' where ' + / ' (' + / ' objname in ("*"' + / " ,%UPCASE('&packageName.IML')" + / " ,%UPCASE('&packageName.CASLUDF')"; /* list of macros */ EOF = 0; do until(EOF); set &filesWithCodes. end = EOF nobs = NOBS; if not (upcase(type)=:'MACRO') then continue; - put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put ' %put NOTE- ;'; - put ' ,"' fileshort upcase64. '"' /; + put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / ' %put NOTE- ;' + / ' ,"' fileshort upcase64. '"'; end; /**/ - put ' )'; - put ' and objtype = "MACRO"'; - put ' and libname = "WORK"'; - put ' )'; - put ' or'; - put ' ('; - put ' objname in ("*"' /; + put ' )' + / ' and objtype = "MACRO"' + / ' and libname = "WORK"' + / ' )' + / ' or' + / ' (' + / ' objname in ("*"'; /* list of formats */ isFormat = 0; EOF = 0; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'FORMAT') then continue; - put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put ' %put NOTE- ;'; - put ' ,"' fileshort upcase64. '"' /; + put ' %put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / ' %put NOTE- ;' + / ' ,"' fileshort upcase64. '"'; isFormat + 1; end; - put ' )'; - put ' and objtype in ("FORMAT" "FORMATC" "INFMT" "INFMTC")'; - put ' and libname = "WORK"'; - put " and memname = '%upcase(&packageName.format)'"; - put ' )'; - - put ' order by objtype, memname, objname'; - put ' ;'; - put 'quit;'; - - put 'data _null_;'; - put ' do until(last.memname);'; - put ' set WORK._last_;'; - put ' by objtype memname;'; - put ' if first.memname then call execute("proc catalog cat = work." !! strip(memname) !! " force;");'; - put ' call execute("delete " !! strip(objname) !! " / et =" !! objtype !! "; run;");'; - put ' end;'; - put ' call execute("quit;");'; - put 'run;'; - put 'proc delete data = WORK._last_;'; - put 'run;'; + put ' )' + / ' and objtype in ("FORMAT" "FORMATC" "INFMT" "INFMTC")' + / ' and libname = "WORK"' + / " and memname = '%upcase(&packageName.format)'" + / ' )' + / ' order by objtype, memname, objname' + / ' ;' + / 'quit;' + / 'data _null_;' + / ' do until(last.memname);' + / ' set WORK._last_;' + / ' by objtype memname;' + / ' if first.memname then call execute("proc catalog cat = work." !! strip(memname) !! " force;");' + / ' call execute("delete " !! strip(objname) !! " / et =" !! objtype !! "; run;");' + / ' end;' + / ' call execute("quit;");' + / 'run;' + / 'proc delete data = WORK._last_;' + / 'run;'; /* delete the link to the formats catalog */ if isFormat then do; - put "proc delete data = work.&packageName.format(mtype = catalog);"; - put 'run;'; - put 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));'; - put 'options fmtsearch = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(fmtsearch))' / - ', %str(()) ))));'; - put '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));' /; + put "proc delete data = work.&packageName.format(mtype = catalog);" + / 'run;' + / 'options fmtsearch = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(fmtsearch))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.))format" '), %str() ))));' + / 'options fmtsearch = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(fmtsearch))' + / ', %str(()) ))));' + / '%put NOTE:[FMTSEARCH] %sysfunc(getoption(fmtsearch));'; end; /* delete proto functions */ @@ -3923,22 +3983,22 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'PROTO') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' /; isProto + 1; end; /* delete the link to the proto functions dataset */ if isProto then do; - put "proc delete data = work.&packageName.proto;"; - put "run;" /; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /; + put "proc delete data = work.&packageName.proto;" + / "run;" + / 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.proto))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));'; end; @@ -3949,9 +4009,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'FUNCTION') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;'; - put 'deletefunc ' fileshort ';' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' + / 'deletefunc ' fileshort ';'; isFunction + 1; end; put "run;" /; @@ -3959,13 +4019,13 @@ data _null_; /* delete the link to the functions dataset */ if isFunction then do; - put 'options cmplib = (%unquote(%sysfunc(tranwrd(' / - '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' / - ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));'; - put 'options cmplib = (%unquote(%sysfunc(compress(' / - '%sysfunc(getoption(cmplib))' / - ',%str(()) ))));'; - put '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));' /; + put 'options cmplib = (%unquote(%sysfunc(tranwrd(' + / '%sysfunc(lowcase(%sysfunc(getoption(cmplib))))' + / ',%str(' "work.%sysfunc(lowcase(&packageName.fcmp))" '), %str() ))));' + / 'options cmplib = (%unquote(%sysfunc(compress(' + / '%sysfunc(getoption(cmplib))' + / ',%str(()) ))));' + / '%put; %put NOTE:[CMPLIB] %sysfunc(getoption(cmplib));'; end; /* delete IML modules */ @@ -3975,12 +4035,12 @@ data _null_; if not (upcase(type)=:'IMLMODULE') then continue; if first.iml then do; - put "proc delete lib=WORK data=&packageName.IML (memtype=catalog); "; - put "run; "; + put "proc delete lib=WORK data=&packageName.IML (memtype=catalog); " + / "run; "; first.IML = 0; end; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' /; /* put 'remove module = ' fileshort ';'; */ end; @@ -3990,9 +4050,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type) in: ('DATA')) then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;'; - put '%put NOTE- ;'; - put '%sysfunc(ifc(%sysfunc(exist(' fileshort ')),drop table ' fileshort ',));' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be deleted;' + / '%put NOTE- ;' + / '%sysfunc(ifc(%sysfunc(exist(' fileshort ')),drop table ' fileshort ',));'; end; put "quit;" /; @@ -4019,9 +4079,9 @@ data _null_; do until(EOF); set &filesWithCodes. end = EOF; if not (upcase(type)=:'LIBNAME') then continue; - put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be cleared;'; - put '%put NOTE- ;'; - put 'libname ' fileshort ' clear;' /; + put '%put NOTE- Element of type ' type 'generated from the file "' file +(-1) '" will be cleared;' + / '%put NOTE- ;' + / 'libname ' fileshort ' clear;'; end; put "run;" /; @@ -4030,46 +4090,45 @@ data _null_; length packageReqPackages $ 32767; packageReqPackages = lowcase(symget('packageReqPackages')); /* note to unload required packages */ - put 'data _null_ ; '; - put ' length req name $ 64; '; - put ' put "NOTE-" / "NOTE: To unload additional required SAS packages execute: " / "NOTE-"; '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' name = strip(kscanx(req, 1, "(")); '; - put ' put '' %unloadPackage( '' name ")" ; '; - put ' end ; '; - put ' put "NOTE-" / "NOTE-"; stop; '; - put 'run; ' /; + put 'data _null_ ; ' + / ' length req name $ 64; ' + / ' put "NOTE-" / "NOTE: To unload additional required SAS packages execute: " / "NOTE-"; ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' name = strip(kscanx(req, 1, "(")); ' + / ' put '' %unloadPackage( '' name ")" ; ' + / ' end ; ' + / ' put "NOTE-" / "NOTE-"; stop; ' + / 'run; '; %end; /* update SYSloadedPackages global macrovariable */ - put 'data _null_ ; '; - put ' length SYSloadedPackages $ 32767; '; - put ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then '; - put ' do; '; - put ' do until(EOF); '; - put ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; '; - put ' substr(SYSloadedPackages, 1+offset, 200) = value; '; - put ' end; '; - put ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); '; - - put " if INDEX(lowcase(SYSloadedPackages),'#%sysfunc(lowcase(&packageName.(&packageVersion.)))#')>0 then "; - put ' do; '; - put " SYSloadedPackages = tranwrd(SYSloadedPackages, '#&packageName.(&packageVersion.)#', '##'); "; - put ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); '; - put ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); '; - put ' put "NOTE: " SYSloadedPackages = ; '; - put ' end ; '; - put ' end; '; - put ' stop; '; - put 'run; ' / ; + put 'data _null_ ; ' + / ' length SYSloadedPackages $ 32767; ' + / ' if SYMEXIST("SYSloadedPackages") = 1 and SYMGLOBL("SYSloadedPackages") = 1 then ' + / ' do; ' + / ' do until(EOF); ' + / ' set sashelp.vmacro(where=(scope="GLOBAL" and name="SYSLOADEDPACKAGES")) end=EOF; ' + / ' substr(SYSloadedPackages, 1+offset, 200) = value; ' + / ' end; ' + / ' SYSloadedPackages = cats("#", translate(strip(SYSloadedPackages), "#", " "), "#"); ' + / " if INDEX(lowcase(SYSloadedPackages),'#%sysfunc(lowcase(&packageName.(&packageVersion.)))#')>0 then " + / ' do; ' + / " SYSloadedPackages = tranwrd(SYSloadedPackages, '#&packageName.(&packageVersion.)#', '##'); " + / ' SYSloadedPackages = compbl(translate(SYSloadedPackages, " ", "#")); ' + / ' call symputX("SYSloadedPackages", SYSloadedPackages, "G"); ' + / ' put "NOTE: " SYSloadedPackages = ; ' + / ' end ; ' + / ' end; ' + / ' stop; ' + / 'run; ' - put '%put NOTE: ' "Unloading package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;'; - put '%put NOTE- ;' /; + / '%put NOTE: ' "Unloading package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / '%put NOTE- ;' - put "/* unload.sas end */"; + / "/* unload.sas end */"; stop; run; @@ -4085,50 +4144,50 @@ data _null_; file &zipReferrence.(preview.sas) encoding = &packageEncoding.; length strX $ 32767; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;"; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;" - put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; - put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; - put ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); '; - put ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); '; - put ' %put NOTE- ;'; - put ' %put NOTE- *** START ***;' /; + / ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; ' + / ' %put NOTE- ' @; put "Generated: &packageGenerated.; " + / ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); ' + / ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); ' + / ' %put NOTE- ;' + / ' %put NOTE- *** START ***;'; /* Use helpKeyword macrovariable to search for content (filename and type) */ /* put '%local ls_tmp ps_tmp notes_tmp source_tmp; ';*/ - put '%let ls_tmp = %sysfunc(getoption(ls)); '; - put '%let ps_tmp = %sysfunc(getoption(ps)); '; - put '%let notes_tmp = %sysfunc(getoption(notes)); '; - put '%let source_tmp = %sysfunc(getoption(source)); '; - put 'options ls = MAX ps = MAX nonotes nosource; '; - put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /; + put '%let ls_tmp = %sysfunc(getoption(ls)); ' + / '%let ps_tmp = %sysfunc(getoption(ps)); ' + / '%let notes_tmp = %sysfunc(getoption(notes)); ' + / '%let source_tmp = %sysfunc(getoption(source)); ' + / 'options ls = MAX ps = MAX nonotes nosource; ' + / '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " - put 'data _null_; '; - put ' if strip(symget("helpKeyword")) = " " then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(description.sas) end = EOF; "; - put ' input; '; - put ' put _infile_; '; - put ' end; '; - put ' else stop; '; - put 'run; ' /; + / 'data _null_; ' + / ' if strip(symget("helpKeyword")) = " " then ' + / ' do until (EOF); ' + / " infile &_PackageFileref_.(description.sas) end = EOF; " + / ' input; ' + / ' put _infile_; ' + / ' end; ' + / ' else stop; ' + / 'run; ' - put 'data WORK._%sysfunc(datetime(), hex16.)_; '; - put 'infile cards4 dlm = "/"; '; - put 'input @; '; - put 'if 0 then output; '; - put 'length helpKeyword $ 64; '; - put 'retain helpKeyword "*"; '; - put 'drop helpKeyword; '; - put 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); '; - put 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then '; - put ' do; '; - put ' input (folder order type file fileshort) (: $ 256.); '; - put ' output; '; - put ' end; '; - put 'cards4; '; + / 'data WORK._%sysfunc(datetime(), hex16.)_; ' + / 'infile cards4 dlm = "/"; ' + / 'input @; ' + / 'if 0 then output; ' + / 'length helpKeyword $ 64; ' + / 'retain helpKeyword "*"; ' + / 'drop helpKeyword; ' + / 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); ' + / 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then ' + / ' do; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / ' end; ' + / 'cards4; '; EOFDS = 0; do until(EOFDS); @@ -4151,42 +4210,42 @@ data _null_; put strX; end; - put ";;;;"; - put "run;" /; + put ";;;;" + / "run;"; /* loop through content found and print info to the log */ - put 'data _null_; '; - put 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; '; - put 'if NOBS = 0 then do; ' / - 'put; put '' *> No preview. Try %previewPackage(packageName,*) to display all.''; put; stop; ' / - 'end; '; - put ' do until(EOFDS); '; - put ' set WORK._last_ end = EOFDS nobs = NOBS; '; - put ' length memberX $ 1024; '; - put ' memberX = cats("_",folder,".",file); '; + put 'data _null_; ' + / 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; ' + / 'if NOBS = 0 then do; ' + / 'put; put '' *> No preview. Try %previewPackage(packageName,*) to display all.''; put; stop; ' + / 'end; ' + / ' do until(EOFDS); ' + / ' set WORK._last_ end = EOFDS nobs = NOBS; ' + / ' length memberX $ 1024; ' + / ' memberX = cats("_",folder,".",file); ' /* inner data step in call execute to read each embedded file */ - put ' call execute("data _null_; ");'; - put " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');"; - put ' call execute(" do until(EOF); ");'; - put ' call execute(" input; ");'; - put ' call execute(" put _infile_; ");'; - put ' call execute(" end; ");'; - put ' call execute(" put "" "" / "" ""; ");'; - put ' call execute(" stop; ");'; - put ' call execute("run; ");'; + / ' call execute("data _null_; ");' + / " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');" + / ' call execute(" do until(EOF); ");' + / ' call execute(" input; ");' + / ' call execute(" put _infile_; ");' + / ' call execute(" end; ");' + / ' call execute(" put "" "" / "" ""; ");' + / ' call execute(" stop; ");' + / ' call execute("run; ");' /**/ - put " end; "; - put " stop; "; - put "run; "; + / " end; " + / " stop; " + / "run; " /* clean-up */ - put "proc delete data = WORK._last_; "; - put "run; "; - put 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' /; + / "proc delete data = WORK._last_; " + / "run; " + / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' - put '%put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* preview.sas end */"; + / '%put NOTE: '"Preview of the &packageName. package, version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* preview.sas end */"; stop; run; @@ -4203,37 +4262,36 @@ data _null_; file &zipReferrence.(help.sas) encoding = &packageEncoding.; length strX $ 32767; - put "filename &_PackageFileref_. list;" /; - put ' %put NOTE- ;'; - put ' %put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;"; + put "filename &_PackageFileref_. list;" + / ' %put NOTE- ;' + / ' %put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;" - put ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; '; - put ' %put NOTE- ' @; put "Generated: &packageGenerated.; "; - put ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); '; - put ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); '; - put ' %put NOTE- ;'; - put ' %put NOTE- *** START ***;' /; + / ' %put NOTE: ' @; put '*** %superq(packageTitle) ***; ' + / ' %put NOTE- ' @; put "Generated: &packageGenerated.; " + / ' %put NOTE- ' @; put 'Author(s): %superq(packageAuthor); ' + / ' %put NOTE- ' @; put 'Maintainer(s): %superq(packageMaintainer); ' + / ' %put NOTE- ;' + / ' %put NOTE- *** START ***;' /* Use helpKeyword macrovariable to search for content (filename and type) */ /* put '%local ls_tmp ps_tmp notes_tmp source_tmp; ';*/ - put '%let ls_tmp = %sysfunc(getoption(ls)); '; - put '%let ps_tmp = %sysfunc(getoption(ps)); '; - put '%let notes_tmp = %sysfunc(getoption(notes)); '; - put '%let source_tmp = %sysfunc(getoption(source)); '; - put 'options ls = MAX ps = MAX nonotes nosource; '; - put '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " /; - - put 'data _null_; '; - put ' if strip(symget("helpKeyword")) = " " then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(description.sas) end = EOF; "; - put ' input; '; - put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; '; - put ' if printer then put "| " _infile_; '; - put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; '; - put ' end; '; - put ' else stop; '; + / '%let ls_tmp = %sysfunc(getoption(ls)); ' + / '%let ps_tmp = %sysfunc(getoption(ps)); ' + / '%let notes_tmp = %sysfunc(getoption(notes)); ' + / '%let source_tmp = %sysfunc(getoption(source)); ' + / 'options ls = MAX ps = MAX nonotes nosource; ' + / '%include' " &_PackageFileref_.(packagemetadata.sas) / nosource2; " + / 'data _null_; ' + / ' if strip(symget("helpKeyword")) = " " then ' + / ' 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; ' + / ' else stop; '; put ' put ; put " Package contains: "; '; EOFDS = 0; @@ -4249,34 +4307,34 @@ data _null_; %do; length packageRequired $ 32767; packageRequired = symget('packageRequired'); - put ' length req $ 256; '; - put ' put ; put " Required SAS Components: "; '; - put ' do req = ' / packageRequired / ' ; '; - put ' put @3 "-" @5 req; '; - put ' end ; '; + put ' length req $ 256; ' + / ' put ; put " Required SAS Components: "; ' + / ' do req = ' / packageRequired / ' ; ' + / ' put @3 "-" @5 req; ' + / ' end ; '; %end; %if %superq(packageReqPackages) ne %then %do; length packageReqPackages $ 32767; packageReqPackages = symget('packageReqPackages'); - put ' length req $ 256; '; - put ' put ; put " Required SAS Packages: "; '; - put ' do req = ' / packageReqPackages / ' ; '; - put ' put @3 "-" @5 req; '; - put ' end ; '; + put ' length req $ 256; ' + / ' put ; put " Required SAS Packages: "; ' + / ' do req = ' / packageReqPackages / ' ; ' + / ' put @3 "-" @5 req; ' + / ' end ; '; %end; %if %superq(additionalContent) NE %then %do; - put 'put ;' / 'put @3 ''Package contains additional content, run: %loadPackageAddCnt(' "&packageName." ') to load it'';'; - put "put @3 'or look for the %sysfunc(lowcase(&packageName.))_AdditionalContent directory in the Packages fileref';"; - put "put @3 'localization (only if additional content was deployed during the installation process).';" / "put ;"; + put 'put ;' / 'put @3 ''Package contains additional content, run: %loadPackageAddCnt(' "&packageName." ') to load it'';' + / "put @3 'or look for the %sysfunc(lowcase(&packageName.))_AdditionalContent directory in the Packages fileref';" + / "put @3 'localization (only if additional content was deployed during the installation process).';" / "put ;"; %end; put 'put " " / @3 "---------------------------------------------------------------------" / " ";' - / 'put @3 "*SAS package generated by SAS Package Framework, version `20251221`*";' + / 'put @3 "*SAS package generated by SAS Package Framework, version `20251231`*";' / "put @3 '*under `&sysscp.`(`&sysscpl.`) operating system,*';" / "put @3 '*using SAS release: `&sysvlong4.`.*';" / 'put " " / @3 "---------------------------------------------------------------------";'; @@ -4284,30 +4342,30 @@ data _null_; put 'run; ' /; /* license info */ - put 'data _null_; '; - put ' if upcase(strip(symget("helpKeyword"))) = "LICENSE" then '; - put ' do until (EOF); '; - put " infile &_PackageFileref_.(license.sas) end = EOF; "; - put ' input; '; - put ' put "| " _infile_; '; - put ' end; '; - put ' else stop; '; - put 'run; ' /; + put 'data _null_; ' + / ' if upcase(strip(symget("helpKeyword"))) = "LICENSE" then ' + / ' do until (EOF); ' + / " infile &_PackageFileref_.(license.sas) end = EOF; " + / ' input; ' + / ' put "| " _infile_; ' + / ' end; ' + / ' else stop; ' + / 'run; '; - put 'data WORK._%sysfunc(datetime(), hex16.)_; '; - put 'infile cards4 dlm = "/"; '; - put 'input @; '; - put 'if 0 then output; '; - put 'length helpKeyword $ 64; '; - put 'retain helpKeyword "*"; '; - put 'drop helpKeyword; '; - put 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); '; - put 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then '; - put ' do; '; - put ' input (folder order type file fileshort) (: $ 256.); '; - put ' output; '; - put ' end; '; - put 'cards4; '; + put 'data WORK._%sysfunc(datetime(), hex16.)_; ' + / 'infile cards4 dlm = "/"; ' + / 'input @; ' + / 'if 0 then output; ' + / 'length helpKeyword $ 64; ' + / 'retain helpKeyword "*"; ' + / 'drop helpKeyword; ' + / 'if _N_ = 1 then helpKeyword = strip(symget("helpKeyword")); ' + / 'if FIND(_INFILE_, helpKeyword, "it") or helpKeyword = "*" then ' + / ' do; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / ' end; ' + / 'cards4; '; EOFDS = 0; do until(EOFDS); @@ -4338,55 +4396,55 @@ data _null_; put 'run;'; */ /* loop through content found and print info to the log */ - put 'data _null_; '; - put 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; '; - put 'if NOBS = 0 then do; ' / - 'put; put '' *> No help info found. Try %helpPackage(packageName,*) to display all.''; put; stop; ' / - 'end; '; - put ' do until(EOFDS); '; - put ' set WORK._last_ end = EOFDS nobs = NOBS; '; - put ' length memberX $ 1024; '; - put ' memberX = cats("_",folder,".",file); '; + put 'data _null_; ' + / 'if upcase(strip(symget("helpKeyword"))) in (" " "LICENSE") then do; stop; end; ' + / 'if NOBS = 0 then do; ' + / 'put; put '' *> No help info found. Try %helpPackage(packageName,*) to display all.''; put; stop; ' + / 'end; ' + / ' do until(EOFDS); ' + / ' set WORK._last_ end = EOFDS nobs = NOBS; ' + / ' length memberX $ 1024; ' + / ' memberX = cats("_",folder,".",file); ' /* inner data step in call execute to read each embedded file */ - put ' call execute("data _null_; ");'; - put " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');"; - put ' call execute(" printer = 0; ");'; - put ' call execute(" do until(EOF); ");'; - put ' call execute(" input; ");'; - put ' call execute(" _endhelpline_ = upcase(reverse(strip(_infile_))); ");'; - put ' call execute(" if 18 <= lengthn(_endhelpline_) AND _endhelpline_ '; - put ' =: ''/*** DNE PLEH ***/'' then printer = 0; ");'; /* ends with HELP END */ - put ' call execute(" if printer then put ""| "" _infile_; ");'; - put ' call execute(" _starthelpline_ = upcase(strip(_infile_)); ");'; - put ' call execute(" if 20 <= lengthn(_starthelpline_) AND _starthelpline_ '; - put ' =: ''/*** HELP START ***/'' then printer = 1; ");'; /* starts with HELP START */ - put ' call execute(" end; ");'; - put ' call execute(" put "" "" / "" ""; ");'; - put ' call execute(" stop; ");'; - put ' call execute("run; ");'; - put ' if lowcase(type) in ("data" "lazydata") then '; - put ' do; '; - put ' call execute("title ""Dataset " || strip(fileshort) || " from package &packageName. ""; ");'; - put ' if exist(fileshort) then call execute("proc contents data = " || strip(fileshort) || "; run; ");'; - put ' else call execute("data _null_; put ""| Dataset " || strip(fileshort) || " does not exist.""; run;");'; - put ' call execute("title; ");'; - put ' end; '; + / ' call execute("data _null_; ");' + / " call execute('infile &_PackageFileref_.(' || strip(memberX) || ') end = EOF; ');" + / ' call execute(" printer = 0; ");' + / ' call execute(" do until(EOF); ");' + / ' call execute(" input; ");' + / ' 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(" stop; ");' + / ' call execute("run; ");' + / ' if lowcase(type) in ("data" "lazydata") then ' + / ' do; ' + / ' call execute("title ""Dataset " || strip(fileshort) || " from package &packageName. ""; ");' + / ' if exist(fileshort) then call execute("proc contents data = " || strip(fileshort) || "; run; ");' + / ' else call execute("data _null_; put ""| Dataset " || strip(fileshort) || " does not exist.""; run;");' + / ' call execute("title; ");' + / ' end; ' /**/ - put " end; "; - put " stop; "; - put "run; "; + / " end; " + / " stop; " + / "run; "; /* clean up */ - put "proc delete data = WORK._last_; "; - put "run; "; + put "proc delete data = WORK._last_; " + / "run; "; /* generate dataset witch content information */ - put 'data &packageContentDS. _NULL_; ' - / ' if "&packageContentDS." = " " then stop; ' - / ' infile cards4 dlm = "/"; ' - / ' input (folder order type file fileshort) (: $ 256.); ' - / ' output; ' - / 'cards4; ' + put 'data &packageContentDS. _NULL_; ' + / ' if "&packageContentDS." = " " then stop; ' + / ' infile cards4 dlm = "/"; ' + / ' input (folder order type file fileshort) (: $ 256.); ' + / ' output; ' + / 'cards4; ' ; EOFDS = 0; @@ -4400,12 +4458,11 @@ data _null_; put ";;;;" / "run;" - / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; ' - / ; + / 'options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.; '; - put '%put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;"; - put '%put NOTE- *** END ***;' /; - put "/* help.sas end */"; + put '%put NOTE: '"Help for package &packageName., version &packageVersion., license &packageLicense.;" + / '%put NOTE- *** END ***;' + / "/* help.sas end */"; stop; run; @@ -4430,7 +4487,7 @@ data _null_; if (upcase(type) not in: ('TEST' 'ADDCNT')); /* test files and additional content are not to be copied */ call execute(cat ('filename _SPFIN_ "', catx('/', base, folder, file), '";')); - call execute(cats("filename _SPFOUT_ ZIP '", base, "/%sysfunc(lowcase(&packageName.)).zip' member='_", folder, ".", file, "';") ); + call execute(cats("filename _SPFOUT_ ZIP '", build, "/%sysfunc(lowcase(&packageName.)).zip' member='_", folder, ".", file, "';") ); /* copy code file into the zip */ call execute('data _null_;'); @@ -4485,7 +4542,7 @@ data _null_; "help " ; /* test if "driving" files exist */ - call execute(cats("filename _SPFOUT_ ZIP '", base, "/%sysfunc(lowcase(&packageName.)).zip' member='", drivFile, ".sas';") ); + call execute(cats("filename _SPFOUT_ ZIP '", build, "/%sysfunc(lowcase(&packageName.)).zip' member='", drivFile, ".sas';") ); call execute('data _null_;'); call execute(' pathname = pathname("_SPFIN_");'); call execute(' ex = fexist("_SPFOUT_");'); @@ -4622,7 +4679,7 @@ filename &zipReferrence. clear; %put NOTE- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^; %put NOTE-; - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; + filename &zipReferrence. "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; filename &zipReferrence. list; %local notesSourceOptions; %let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source)); @@ -4652,7 +4709,75 @@ filename &zipReferrence. clear; options ¬esSourceOptions.; filename &zipReferrence. clear; %end; -/*-+++++++++++++++++++++++-*/ +/*-+++++++++++++++++++++++-*/ /*-+++++++++++++++++++++++-*/ /*-+++++++++++++++++++++++-*/ /*-+++++++++++++++++++++++-*/ + + +/*---------------------------------------------------------------- * +* * +* tests for a package are encapsulated in the next macro * +* * +* ---------------------------------------------------------------- */ +/* locate sas binaries for testing part of the framework */ +%local SASROOT SASEXE SASWORK; + +/* location of the config file */ +%local SASCONFIG; /* by default a local macrovariable is empty, so no file would be pointed as a config file */ + +/* temporary location for tests results is WORK unless developer provide &testResults. */ +%local testPackageTimesamp; + +/* location for test and test work */ +%local dirForTest dirForTestWork; + +%SPFint_gnPckg_tests() + +/*------------------------------------------------------------------- * +* * +* markdown documentation generation is encapsulated in the next macro * +* * +* ------------------------------------------------------------------- */ +%SPFint_gnPckg_markdown() + +/*-------------------------------------------------------------------- * +* * +* copying (with version in the name) is encapsulated in the next macro * +* * +* -------------------------------------------------------------------- */ +%SPFint_gnPckg_arch() + + +/* clean temporary files */ +proc sql; + drop table &filesWithCodes.; + + %if %sysfunc(exist(&filesWithCodes.addCnt)) %then + %do; + drop table &filesWithCodes.addCnt; + %end; + + %if %sysfunc(exist(&filesWithCodes.markdown)) %then + %do; + drop table &filesWithCodes.markdown; + %end; +quit; + +/* turn on the original value of the note about quoted string length */ +options &qlenmax_fstimer_tmp.; + +%ENDofgeneratePackage: +%put --- generatePackage END ---; +%mend generatePackage; + + +/* START macros extracted outside generatePackage macro */ + +/*+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 @@ -4664,7 +4789,7 @@ filename &zipReferrence. clear; %end; /* tests of package are executed by default */ -%if %bquote(&testPackage.) ne Y %then +%if NOT (%superq(testPackage) in (Y y 1)) %then %do; %put WARNING: ** NO TESTING WILL BE EXECUTED. **; %GOTO NOTESTING; @@ -4717,31 +4842,31 @@ run; /* load */ put @n '%loadpackage'"(&packageName.,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; put @n '%loadpackage'"(&packageName.,"; - put @n " path=&filesLocation., lazyData=*)" /; + put @n " path=&buildLocation., lazyData=*)" /; /* help */ put @n '%helpPackage'"(&packageName.,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; put @n '%helpPackage'"(&packageName.,*,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; put @n '%helpPackage'"(&packageName.,License,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; /* preview */ put @n '%previewPackage'"(&packageName.,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; put @n '%previewPackage'"(&packageName.,*,"; - put @n " path=&filesLocation.)" /; + put @n " path=&buildLocation.)" /; /* unload */ put @n '%unloadPackage'"(&packageName.,"; - put @n " path=&filesLocation.) " /; + put @n " path=&buildLocation.) " /; /* additional content */ put @n '%loadPackageAddCnt'"(&packageName.,"; - put @n " path=&filesLocation.) " /; + put @n " path=&buildLocation.) " /; put ; put '***************************************************'; @@ -4751,8 +4876,8 @@ run; %end; -/* locate sas binaries */ -%local SASROOT SASEXE SASWORK; +/* 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; @@ -4803,7 +4928,7 @@ run; %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 */ +/**** %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; @@ -4831,7 +4956,7 @@ run; options DLCREATEDIR; /* turns-on creation of subdirectories by libname */ /* temporary location for tests results is WORK unless developer provide &testResults. */ -%local testPackageTimesamp; +/**** %local testPackageTimesamp; ****/ %let testPackageTimesamp = %sysfunc(lowcase(&packageName._%sysfunc(datetime(),b8601dt15.))); %if %qsysfunc(fileexist(%superq(testResults))) %then %do; @@ -4884,7 +5009,7 @@ options DLCREATEDIR; /* turns-on creation of subdirectories by libname */ libname TESTWORK "&SASWORK./testwork_&testPackageTimesamp."; %end; -%local dirForTest dirForTestWork; +/**** %local dirForTest dirForTestWork; ****/ %let dirForTest = %sysfunc(pathname(TEST)); %let dirForTestWork = %sysfunc(pathname(TESTWORK)); %put ; @@ -4898,9 +5023,9 @@ 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 filesLocation is used as a replacement */ -%if %bquote(&packages.)= %then %let packages=%sysfunc(pathname(packages)); -%if %bquote(&packages.)= %then %let packages=&filesLocation.; +/* 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.; @@ -4936,23 +5061,23 @@ data _null_; /* load */ put '%loadpackage'"(&packageName.," - / " path=&filesLocation.)" /; + / " path=&buildLocation.)" /; put '%loadpackage'"(&packageName.," - / " path=&filesLocation., lazyData=*)" /; + / " path=&buildLocation., lazyData=*)" /; /* help */ put '%helpPackage'"(&packageName.," - / " path=&filesLocation.)" /; + / " path=&buildLocation.)" /; put '%helpPackage'"(&packageName.,*," - / " path=&filesLocation.)" /; + / " path=&buildLocation.)" /; put '%helpPackage'"(&packageName.,License," - / " path=&filesLocation.)" /; + / " path=&buildLocation.)" /; /* preview */ put '%previewPackage'"(&packageName.,"; - put " path=&filesLocation.)" /; + put " path=&buildLocation.)" /; put '%previewPackage'"(&packageName.,*,"; - put " path=&filesLocation.)" /; + put " path=&buildLocation.)" /; /*check if package elements realy exist*/ EOF = 0; @@ -4997,13 +5122,13 @@ data _null_; /* unload */ put '%unloadPackage'"(&packageName.," - / " path=&filesLocation.) " /; + / " path=&buildLocation.) " /; /* additional content */ put '%loadPackageAddCnt'"(&packageName.," - / " path=&filesLocation.) " /; + / " path=&buildLocation.) " /; - put "filename packages '&filesLocation.';" + put "filename packages '&buildLocation.';" / '%listPackages() ' /; /* check if work should be deleted after test is done */ @@ -5114,7 +5239,7 @@ data _null_; run; -%local t; +%local t; %do t = 1 %to &numberOfTests.; /* each test is executed with autoexec loading the package */ data _null_; @@ -5157,9 +5282,9 @@ data _null_; put '%include packages(loadpackage.sas);' /; /* for older versions when the SPFinit.sas did not exist */ put '%loadpackage'"(&packageName.,"; - put " path=&filesLocation.)" /; + put " path=&buildLocation.)" /; put '%loadpackage'"(&packageName.,"; - put " path=&filesLocation., lazyData=*)" /; + put " path=&buildLocation., lazyData=*)" /; if 0 = delTestWork then put "options NOWORKTERM;"/; @@ -5285,12 +5410,29 @@ options "elenmax_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; + + + +/*+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 %superq(markdownDoc)=1 %then +%if &markdownDoc.=1 %then %do; %if %superq(createPackageContentStatus) NE 0 %then %do; @@ -5310,8 +5452,8 @@ options "elenmax_tmp.; %sysfunc(getoption(notes)) %sysfunc(getoption(source)) msglevel=%sysfunc(getoption(msglevel)); options NOnotes NOsource msglevel=N; -filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).md"; -filename &_PackageFileref_. ZIP "&filesLocation./%sysfunc(lowcase(&packageName.)).zip"; +filename &zipReferrence. "&buildLocation./%sysfunc(lowcase(&packageName.)).md"; +filename &_PackageFileref_. ZIP "&buildLocation./%sysfunc(lowcase(&packageName.)).zip"; data &filesWithCodes.markdown; /* break if no data */ @@ -5392,7 +5534,7 @@ data &filesWithCodes.markdown; %end; put " " / "---------------------------------------------------------------------" / " " - / "*SAS package generated by SAS Package Framework, version `20251221`,*" + / "*SAS package generated by SAS Package Framework, version `20251231`,*" / "*under `&sysscp.`(`&sysscpl.`) operating system,*" / "*using SAS release: `&sysvlong4.`.*" / " " / "---------------------------------------------------------------------" / " "; @@ -5518,7 +5660,28 @@ 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; + + +/*+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; @@ -5534,74 +5697,73 @@ options &MarkDownOptionsTmp.; %let notesSourceOptions = %sysfunc(getoption(notes)) %sysfunc(getoption(source)); options NOnotes NOsource; - /* zip */ - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).zip" lrecl=1 recfm=n; - filename &zipReferrence. list; - filename &zipReferrenceV. "&filesLocation./%sysfunc(lowcase(&packageName.))_&packageVersion._.zip" lrecl=1 recfm=n; - filename &zipReferrenceV. list; - data _null_; - 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._.zip file."; - put rctxt; - end; - else put "Creating %sysfunc(lowcase(&packageName.))_&packageVersion._.zip file."; - run; - filename &zipReferrence. clear; - filename &zipReferrenceV. clear; + %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).; - /* md */ - filename &zipReferrence. "&filesLocation./%sysfunc(lowcase(&packageName.)).md" lrecl=1 recfm=n; - filename &zipReferrence. list; - filename &zipReferrenceV. "&filesLocation./%sysfunc(lowcase(&packageName.))_&packageVersion._.md" lrecl=1 recfm=n; - filename &zipReferrenceV. list; - data _null_; - 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._.md file."; - put rctxt; - end; - else put "Creating %sysfunc(lowcase(&packageName.))_&packageVersion._.md file."; - run; - filename &zipReferrence. clear; - filename &zipReferrenceV. clear; + %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 ¬esSourceOptions.; %end; -/*= generate MarkDown documentation END =================================================================================*/ -%NOmarkdownDoc: +/*= 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; - -/* clean temporary files */ -proc sql; - drop table &filesWithCodes.; - - %if %sysfunc(exist(&filesWithCodes.addCnt)) %then - %do; - drop table &filesWithCodes.addCnt; - %end; - - %if %sysfunc(exist(&filesWithCodes.markdown)) %then - %do; - drop table &filesWithCodes.markdown; - %end; -quit; - -/* turn on the original value of the note about quoted string length */ -options &qlenmax_fstimer_tmp.; - - - -%ENDofgeneratePackage: -%put --- generatePackage END ---; -%mend generatePackage; +/* END macros extracted outside generatePackage macro */ /* @@ -5680,13 +5842,13 @@ TODO: (in Polish) */ )/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)) ; @@ -5696,7 +5858,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 #; @@ -5794,12 +5956,12 @@ parmbuff 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)) ; @@ -5809,7 +5971,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 #; @@ -5877,7 +6039,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; @@ -5890,17 +6052,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; @@ -5922,7 +6085,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 */ @@ -5991,12 +6154,12 @@ des = 'Macro to verify SAS package with the hash digest, version 20251221. Run % */ )/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)) ; @@ -6006,7 +6169,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 #; @@ -6138,13 +6301,13 @@ des = 'Macro to preview content of a SAS package, version 20251221. Run %preview 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)) ; @@ -6154,7 +6317,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 #; @@ -6256,13 +6419,13 @@ filename packages list; 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)) ; @@ -6272,7 +6435,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 #; @@ -6641,12 +6804,12 @@ minoperator ,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)) ; @@ -6657,7 +6820,7 @@ minoperator %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 #; @@ -6702,15 +6865,15 @@ minoperator %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; ); @@ -7033,7 +7196,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_; @@ -7063,8 +7226,10 @@ options &options_tmp2.; ,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 ; @@ -7072,7 +7237,7 @@ options &options_tmp2.; %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)) ; @@ -7082,7 +7247,7 @@ options &options_tmp2.; %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 #; @@ -7207,7 +7372,7 @@ options &options_tmp2.; %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; @@ -7234,8 +7399,9 @@ options &options_tmp2.; %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")); @@ -7385,7 +7551,7 @@ options &options_tmp2.; 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 */ @@ -7613,6 +7779,7 @@ options &options_tmp2.; / "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; @@ -7651,7 +7818,7 @@ options &options_tmp2.; /* LINK 3 */ stopProcessing: - putlog 32*"*" 24*"=" 32*"*"; + putlog 52*"*" 24*"=" 52*"*"; stop; return; @@ -7738,13 +7905,13 @@ filename PACKAGES ("R:\testPackages2" "R:\testPackages1"); 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)) ; @@ -7754,7 +7921,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 #; @@ -7888,7 +8055,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= @@ -7911,6 +8078,8 @@ splitCodeForPackage extendPackagesFileref relocatePackage isPackagesFilerefOK +bundlePackages +unbundlePackages /**/ SasPackagesFrameworkNotes ; @@ -7921,7 +8090,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)) @@ -7932,14 +8101,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 #-------------------------------------------------------------------------------#; @@ -8045,4 +8214,896 @@ options mlogic symbolgen; */ +/*+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. + ¬es_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() +*/ + + +/*+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. + ¬es_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 */