Compare commits

..

5 Commits

Author SHA1 Message Date
Bartosz Jablonski
6c38872ee2 SAS Packages Framework, ver. 20221107
**SAS Packages Framework**, ver. 20221107

- Minor update on the `%generatePackage()` macro log look.
2022-11-07 10:45:29 +01:00
Bartosz Jablonski
d35ac328cc SAS Packages Framework, ver. 20221107
**SAS Packages Framework**, ver. 20221107

- Minor update on the `%generatePackage()` macro log look.
2022-11-07 10:42:30 +01:00
Bartosz Jablonski
e3a813b257 Link to recording from the SAS Explore 2022 conference: "A BasePlus Package for SAS"
Link to recording from the SAS Explore 2022 conference: "A BasePlus Package for SAS"
2022-11-01 17:43:31 +01:00
Bartosz Jablonski
67bd3abd58 SAS Packages Framework, ver. 20221022
**SAS Packages Framework**, ver. `20221022`

In the `%generatePackage()` macro additional quality checks for files of EXEC and CLEAN types were added.
Each EXEC file should have a CLEAN file counterpart and vice versa.
- If the number of EXECs and CLEANs differs but both are positive macro issues a Warning.
- If EXECs are positive but CLEANs are zero (or other way around) macro issues an Error!

Documentation updated.
2022-10-22 22:13:50 +02:00
Bart Jablonski (yabwon)
1968330049 SAS Packages Framework, version 20221002
**SAS Packages Framework**, version `20221002`

- Modifications in the `%installPackage()` macro it is allowed to call installation of packages with version number (if used with `mirror=0`), for example: `%installPackage(baseplus(1.17) macroarray(1.0) dfa(0.5) GSM)`,

- For the `%installPackage()` and in the `%loadPackageS()` macros the list of packages standardised before execution to the form `package1(ver1) package2(ver2) package3(ver3)`,

- Fix for directories "with spaces" for `%installPackage()`.

- Documentation updated.
2022-10-01 12:11:40 +02:00
16 changed files with 413 additions and 94 deletions

View File

@@ -8,7 +8,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 **`20221001`**.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. **The latest version** of SPF is **`20221107`**.
To get started with SAS Packages try this [**`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).
@@ -23,6 +23,7 @@ Short description of the SAS Packages Framework macros can be found [here](https
- [SAS dla Administratorów i Praktyków 2020](https://www.youtube.com/watch?v=mXuep2k48Z8&feature=youtu.be&t=0s "SASAiP2020") (October 2020, in Polish)
- [Boston Area SAS Users Group webinar](https://www.basug.org/videos?wix-vod-video-id=78067e61413d43d3a6951974b3bc3014&wix-vod-comp-id=comp-klv807gt "BASUG") (November 2020)
- [SAS Global Forum 2021 V.E.](https://www.youtube.com/watch?v=hqexaQtGw88 "SGF2021") (May 20th, 2021)
- [SAS Explore 2022](https://communities.sas.com/t5/SAS-Explore-Presentations/A-BasePlus-Package-for-SAS/ta-p/838246 "SASexplore") (September 27th-29th, 2022)
---

View File

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

View File

@@ -23,7 +23,7 @@
default value 1 means "delete tests work" */
)/secure minoperator
/*** HELP END ***/
des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage() for help info.'
des = 'Macro to generate SAS packages, version 20221107. Run %generatePackage() for help info.'
;
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
%do;
@@ -38,7 +38,7 @@ des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage()
%put ### This is short help information for the `generatePackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to generate SAS packages, version `20221001` #;
%put # Macro to generate SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -95,6 +95,7 @@ des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage()
%GOTO ENDofgeneratePackage;
%end;
%put --- generatePackage START ---;
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _DUMMY_ _RC_ _PackageFileref_;
%let zipReferrence = _%sysfunc(datetime(), hex6.)_;
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
@@ -250,7 +251,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
put 'ERROR- ' R;
end;
else
rc = dosubl('title; options nonotes nosource ps=max ls=99 nodate nonumber nostimer;
rc = dosubl('title; options nonotes nosource ps=min ls=99 nodate nonumber nostimer;
data _null_;
length rq $ 64; put "Required:";
do rq = &packageRequired.;
@@ -300,7 +301,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
put 'ERROR- ' R;
end;
else
rc = dosubl('title; options nonotes nosource ps=max ls=66 nodate nonumber nostimer;
rc = dosubl('title; options nonotes nosource ps=min ls=66 nodate nonumber nostimer;
data _null_;
length rq $ 64; put "ReqPackages:";
do rq = &packageReqPackages.;
@@ -572,6 +573,76 @@ options NOnotes NOsource;
proc sort data = &filesWithCodes.;
by order type file;
run;
/* quality check for EXEC and CLEAN types */
data _null_;
set &filesWithCodes. (where=(upcase(type) in ('EXEC' 'CLEAN'))) end=EOF;
if _N_ = 1 then
do;
declare hash EXEC(); /* store EXECs */
EXEC.defineKey('file');
EXEC.defineData('ne');
EXEC.defineDone();
declare hash CLEAN(); /* store CLEANs */
CLEAN.defineKey('file');
CLEAN.defineData('nc');
CLEAN.defineDone();
declare hash F(ordered:"A");
F.defineKey('file');
F.defineData('file');
F.defineDone();
declare hiter IF("F");
end;
F.replace();
if upcase(type) = 'EXEC' then
do;
e + 1;
if EXEC.find() then EXEC.add(key:file,data:1);
else EXEC.replace(key:file,data:ne+1);
end;
if upcase(type) = 'CLEAN' then
do;
c + 1;
if CLEAN.find() then CLEAN.add(key:file,data:1);
else CLEAN.replace(key:file,data:nc+1);
end;
if EOF then
do;
/* 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:';
do while(IF.next()=0);
ne = 0;
nc = 0;
df = EXEC.find();
df = CLEAN.find();
df = abs(ne - nc);
put "WARNING- File " file char36. "EXEC: " ne 3. +1 "CLEAN: " nc 3. +1 "diff: " df 3.;
end;
put "WARNING- ";
end;
/* 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: Aborting package generation!' ;
abort;
end;
end;
run;
/*
proc contents data = &filesWithCodes.;
run;
@@ -1605,7 +1676,7 @@ data _null_;
put ' end ; ';
%end;
put 'put "***"; put "* SAS package generated by generatePackage, version 20221001 *"; put "***";';
put 'put "***"; put "* SAS package generated by generatePackage, version 20221107 *"; put "***";';
put 'run; ' /;
@@ -2364,7 +2435,7 @@ title;
/*%put _local_;*/
%put NOTE: changing current folder to:;
%put NOTE: Changing current folder to:;
%put NOTE- *%sysfunc(DLGCDIR(%sysfunc(pathname(currdir))))*;
filename CURRDIR clear;
@@ -2384,6 +2455,7 @@ options &qlenmax_fstimer_tmp.;
%ENDofgeneratePackage:
%put --- generatePackage END ---;
%mend generatePackage;

View File

@@ -24,7 +24,7 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to get help about SAS package, version 20221001. Run %helpPackage() for help info.'
des = 'Macro to get help about SAS package, version 20221107. Run %helpPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -39,7 +39,7 @@ des = 'Macro to get help about SAS package, version 20221001. Run %helpPackage()
%put ### This is short help information for the `helpPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to get help about SAS packages, version `20221001` #;
%put # Macro to get help about SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -169,7 +169,7 @@ TODO:
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
*/
/* Macros to install SAS packages, version 20221001 */
/* Macros to install SAS packages, version 20221107 */
/* 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

View File

@@ -14,7 +14,7 @@
/secure
minoperator
/*** HELP END ***/
des = 'Macro to install SAS package, version 20221001. Run %%installPackage() for help info.'
des = 'Macro to install SAS package, version 20221107. Run %%installPackage() for help info.'
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
%do;
@@ -29,7 +29,7 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put ### This is short help information for the `installPackage` macro #;
%put #--------------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to install SAS packages, version `20221001` #;
%put # Macro to install SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -73,6 +73,8 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put # - `version=` Indicates which historical version of a package to install. #;
%put # Historical version are available only if `mirror=0` is set. #;
%put # Default value is null which means "install the latest". #;
%put # When there are multiple packages to install version #;
%put # is scan sequentially. #;
%put # #;
%put # - `replace=` With default value of `1` it causes existing package file #;
%put # to be replaced by new downloaded file. #;
@@ -108,6 +110,23 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put #### Example #################################################################################;
%put # #;
%put # Enabling the SAS Package Framework #;
%put # from the local directory and installing & loading #;
%put # the multiple packages from the Internet. #;
%put # #;
%put # Assume that the `SPFinit.sas` file #;
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
%put # #;
%put # Run the following code in your SAS session: #;
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
%put %nrstr( filename packages "C:/SAS_PACKAGES"; );
%put %nrstr( %%include packages(SPFinit.sas); );
%put ;
%put %nrstr( %%installPackage(baseplus(1.17) macroarray(1.0) dfa(0.5) GSM) );
%put %nrstr( %%loadPackageS(GSM, baseplus(1.17), macroarray(1.0), dfa(0.5)) );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put ##############################################################################################;
%put ;
options &options_tmp.;
@@ -134,8 +153,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/* in case the 'packages' fileref is multi-directory the first directory will be selected as a destination */
data _null_;
/* get the firstPackagesPath */
call symputX("firstPackagesPath", dequote(kscanx(pathname("packages"), 1, "()", "QS")) ,"L");
if "(" =: pathname("packages") then
/* get the firstPackagesPath */
call symputX("firstPackagesPath", dequote(kscanx(pathname("packages"), 1, "()", "QS")), "L");
else
call symputX("firstPackagesPath", pathname("packages"), "L");
run;
%if %superq(sourcePath)= %then
@@ -168,14 +190,51 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%mirrorEnd:
%put INFO: Source path is &sourcePath.;
%end;
%else
%do;
%let mirror=-1;
%let SPFinitMirror = &sourcePath.SPFinit.sas;
%end;
%local i;
%local i str;
/* standardise list of packages */
%let str = %qsysfunc(compress(%superq(packagesNames),[{(. _)}],kad));
%let str = %qsysfunc(translate(%superq(str),[[]],{()}));
%let str = %qsysfunc(transtrn(%superq(str),],%str(] )));
%let str = %qsysfunc(compbl(%superq(str)));
%let str = %qsysfunc(transtrn(%superq(str),%str([ ),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( [),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( ]),]));
%let str = %unquote(&str.);
%let packagesNames = %qsysfunc(translate(%superq(str),(),[]));
%if %length("%sysfunc(compress(%superq(str),[,k))") NE %length("%sysfunc(compress(%superq(str),],k))") %then
%do;
%put ERROR: Syntax error in list of packages!;
%put ERROR- %superq(packagesNames);
%goto packagesListError;
%end;
%put ;
%put INFO: Calling: &packagesNames.;
%do i = 1 %to %sysfunc(countw(&packagesNames., , S));
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
%local packageName packageSubDir;
%let packageName = %scan(&packagesNames., &i., , S);
%local packageName packageSubDir vers versA versB;
%put ;
/*%put ### %scan(&packagesNames., &i., , S) ###;*/
%let packageName = %scan(%scan(&packagesNames., &i., , S),1,{[()]});
%let versA = %scan(%scan(&packagesNames., &i., , S),2,{[()]});
%let versB = %scan(&version., &i., , S);
%let vers=;
%if %superq(versB) ne %then %let vers = &versB.;
%if %superq(versA) ne %then %let vers = &versA.;
%if -1 = &mirror %then /* ignore version when direct path is provided */
%do;
%let vers=;
%end;
%put ### &packageName.(&vers.) ###;
%put *** %lowcase(&packageName.) start *****************************************;
%local in out _IOFileref_;
data _null_; call symputX("_IOFileref_", put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
@@ -188,6 +247,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%if %upcase(&packageName.) in (SPFINIT SASPACKAGEFRAMEWORK SASPACKAGESFRAMEWORK) %then
%do;
/* allows to install/download the framework file like any other package */
%if %superq(mirror) in (0 1) AND (%superq(vers) ne) %then
%do;
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/&vers./SPF/SPFinit.sas;
%end;
filename &in URL
"&SPFinitMirror."
recfm=N lrecl=1;
@@ -200,11 +264,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%if 0 = %superq(mirror) %then
%do;
%let packageSubDir = %lowcase(&packageName.)/raw/main/;
%if %superq(version) ne %then
%if %superq(vers) ne %then
%do;
/*%let packageSubDir = %lowcase(&packageName.)/main/hist/&version./;*/
%let packageSubDir = %lowcase(&packageName.)/raw/&version./;
%let packageSubDir = %lowcase(&packageName.)/raw/&vers./;
%end;
%end;
filename &in URL "&sourcePath.&packageSubDir.%lowcase(&packageName.).zip"
@@ -281,6 +345,8 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
%end;
%packagesListError:
options ls = &ls_tmp. ps = &ps_tmp.
&notes_tmp. &source_tmp.
&stimer_tmp. &fullstimer_tmp.
@@ -392,7 +458,7 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/* Macro to list SAS packages in packages folder.
Version 20221001
Version 20221107
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating

View File

@@ -1,7 +1,7 @@
/*+listPackages+*/
%macro listPackages()/secure PARMBUFF
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20221001.'
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20221107.'
;
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
%do;
@@ -16,7 +16,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 `20221001` #;
%put # Macro to list available SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -166,7 +166,7 @@ options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
/* Macro to generate SAS packages.
Version 20221001
Version 20221107
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating

View File

@@ -27,7 +27,7 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load SAS package, version 20221001. Run %loadPackage() for help info.'
des = 'Macro to load SAS package, version 20221107. Run %loadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -42,7 +42,7 @@ des = 'Macro to load SAS package, version 20221001. Run %loadPackage() for help
%put ### This is short help information for the `loadPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *load* SAS packages, version `20221001` #;
%put # Macro to *load* SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -11,7 +11,7 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load multiple SAS packages at one run, version 20221001. Run %loadPackages() for help info.'
des = 'Macro to load multiple SAS packages at one run, version 20221107. Run %loadPackages() for help info.'
parmbuff
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
@@ -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 `20221001` #;
%put # Macro wrapper for the loadPackage macro, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -76,18 +76,28 @@ parmbuff
%GOTO ENDofloadPackageS;
%end;
%local lengthOfsyspbuff numberOfPackagesNames i packageElement packageName packageVersion;
%local lengthOfsyspbuff numberOfPackagesNames i packageElement packageName packageVersion str;
%let lengthOfsyspbuff = %qsysfunc(length(&syspbuff.));
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), %str((._,)), KDA));
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str(,)));
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), {[(. _,)]}, KDA));
%let str = %qsysfunc(translate(%superq(packagesNames),[[ ]],{(,)}));
%let str = %qsysfunc(transtrn(%superq(str),],%str(] )));
%let str = %qsysfunc(compbl(%superq(str)));
%let str = %qsysfunc(transtrn(%superq(str),%str([ ),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( [),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( ]),]));
%let str = %qsysfunc(translate(%superq(str),(),[]));
%let packagesNames = %unquote(&str.);
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str( )));
%put NOTE: List of packages to be loaded contains &numberOfPackagesNames. element(s).;
%put NOTE- The list is: &packagesNames..;
%put NOTE- ;
%do i = 1 %to &numberOfPackagesNames.;
%let packageElement = %qscan(&packagesNames., &i., %str(,) );
%let packageElement = %qscan(&packagesNames., &i., %str( ) );
%let packageName = %qscan(&packageElement., 1, %str(()));
%let packageVersion = %qscan(&packageElement., 2, %str(()));
%if %superq(packageVersion) = %then %let packageVersion = .;

View File

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

View File

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

View File

@@ -13,7 +13,7 @@
hashing_file() function, SAS 9.4M6 */
)/secure
/*** HELP END ***/
des = 'Macro to verify SAS package with the hash digest, version 20221001. Run %verifyPackage() for help info.'
des = 'Macro to verify SAS package with the hash digest, version 20221107. Run %verifyPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -28,7 +28,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20221001. Run %
%put ### This is short help information for the `verifyPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to verify SAS package with it hash digest, version `20221001` #;
%put # Macro to verify SAS package with it hash digest, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -21,7 +21,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 **`20221001`**.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20221107`**.
**To get started with SAS Packages** try this [**`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).
@@ -39,7 +39,7 @@ After assigning the directory do not change them when using the SPF since it may
## This is short help information for the `installPackage` macro <a name="installpackage"></a>
--------------------------------------------------------------------------------------------
Macro to install SAS packages, version `20221001`
Macro to install SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -82,6 +82,8 @@ After assigning the directory do not change them when using the SPF since it may
- `version=` Indicates which historical version of a package to install.
Historical version are available only if `mirror=0` is set.
Default value is null which means "install the latest".
When there are multiple packages to install version
is scan sequentially.
- `replace=` With default value of `1` it causes existing package file
to be replaced by new downloaded file.
@@ -117,11 +119,29 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### Example ################################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the multiple packages from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES";
%include packages(SPFinit.sas);
%installPackage(baseplus(1.17) macroarray(1.0) dfa(0.5) GSM)
%loadPackageS(GSM, baseplus(1.17), macroarray(1.0), dfa(0.5))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `helpPackage` macro <a name="helppackage"></a>
-------------------------------------------------------------------------------
Macro to get help about SAS packages, version `20221001`
Macro to get help about SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -191,7 +211,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `loadPackage` macro <a name="loadpackage"></a>
-------------------------------------------------------------------------------
Macro to *load* SAS packages, version `20221001`
Macro to *load* SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -264,7 +284,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `loadPackageS` macro <a name="loadpackages"></a>
-------------------------------------------------------------------------------
Macro wrapper for the loadPackage macro, version `20221001`
Macro wrapper for the loadPackage macro, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -313,7 +333,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `unloadPackage` macro <a name="unloadpackage"></a>
-------------------------------------------------------------------------------
Macro to unload SAS packages, version `20221001`
Macro to unload SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -378,7 +398,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `listPackages` macro <a name="listpackages"></a>
-----------------------------------------------------------------------------------------
Macro to list available SAS packages, version `20221001`
Macro to list available SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -419,7 +439,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `verifyPackage` macro <a name="verifypackage"></a>
-------------------------------------------------------------------------------
Macro to verify SAS package with it hash digest, version `20221001`
Macro to verify SAS package with it hash digest, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -473,7 +493,7 @@ filename packages "C:/SAS_PACKAGES"; %* set-up a directory for packages;
## This is short help information for the `previewPackage` macro <a name="previewpackage"></a>
-------------------------------------------------------------------------------
Macro to get previwe of a SAS packages, version `20221001`
Macro to get previwe of a SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -540,7 +560,7 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
## This is short help information for the `generatePackage` macro <a name="generatepackage"></a>
-------------------------------------------------------------------------------
Macro to generate SAS packages, version `20221001`
Macro to generate SAS packages, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -721,7 +741,7 @@ All files have to have `.sas` extension. Other files are ignored.
## This is short help information for the `extendPackagesFileref` macro <a name="extendpackagesfileref"></a>
-----------------------------------------------------------------------------------------
Macro to list directories pointed by 'packages' fileref, version `20221001`
Macro to list directories pointed by 'packages' fileref, version `20221107`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating

View File

@@ -42,7 +42,7 @@
- to unload, or
- to generate SAS packages.
Version 20221001.
Version 20221107.
See examples below.
A SAS package is a zip file containing a group of files
@@ -82,7 +82,7 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load SAS package, version 20221001. Run %loadPackage() for help info.'
des = 'Macro to load SAS package, version 20221107. Run %loadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -97,7 +97,7 @@ des = 'Macro to load SAS package, version 20221001. Run %loadPackage() for help
%put ### This is short help information for the `loadPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to *load* SAS packages, version `20221001` #;
%put # Macro to *load* SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -283,7 +283,7 @@ des = 'Macro to load SAS package, version 20221001. Run %loadPackage() for help
*/
)/secure
/*** HELP END ***/
des = 'Macro to unload SAS package, version 20221001. Run %unloadPackage() for help info.'
des = 'Macro to unload SAS package, version 20221107. Run %unloadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -298,7 +298,7 @@ des = 'Macro to unload SAS package, version 20221001. Run %unloadPackage() for h
%put ### This is short help information for the `unloadPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to unload SAS packages, version `20221001` #;
%put # Macro to unload SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -443,7 +443,7 @@ des = 'Macro to unload SAS package, version 20221001. Run %unloadPackage() for h
*/
)/secure
/*** HELP END ***/
des = 'Macro to get help about SAS package, version 20221001. Run %helpPackage() for help info.'
des = 'Macro to get help about SAS package, version 20221107. Run %helpPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -458,7 +458,7 @@ des = 'Macro to get help about SAS package, version 20221001. Run %helpPackage()
%put ### This is short help information for the `helpPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to get help about SAS packages, version `20221001` #;
%put # Macro to get help about SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -588,7 +588,7 @@ TODO:
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
*/
/* Macros to install SAS packages, version 20221001 */
/* Macros to install SAS packages, version 20221107 */
/* 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
@@ -611,7 +611,7 @@ TODO:
/secure
minoperator
/*** HELP END ***/
des = 'Macro to install SAS package, version 20221001. Run %%installPackage() for help info.'
des = 'Macro to install SAS package, version 20221107. Run %%installPackage() for help info.'
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
%do;
@@ -626,7 +626,7 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put ### This is short help information for the `installPackage` macro #;
%put #--------------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to install SAS packages, version `20221001` #;
%put # Macro to install SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -670,6 +670,8 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put # - `version=` Indicates which historical version of a package to install. #;
%put # Historical version are available only if `mirror=0` is set. #;
%put # Default value is null which means "install the latest". #;
%put # When there are multiple packages to install version #;
%put # is scan sequentially. #;
%put # #;
%put # - `replace=` With default value of `1` it causes existing package file #;
%put # to be replaced by new downloaded file. #;
@@ -705,6 +707,23 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%put %nrstr( %%loadPackage(SQLinDS) %%* load the package content into the SAS session; );
%put %nrstr( %%unloadPackage(SQLinDS) %%* unload the package content from the SAS session; );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put #### Example #################################################################################;
%put # #;
%put # Enabling the SAS Package Framework #;
%put # from the local directory and installing & loading #;
%put # the multiple packages from the Internet. #;
%put # #;
%put # Assume that the `SPFinit.sas` file #;
%put # is located in the "C:/SAS_PACKAGES/" folder. #;
%put # #;
%put # Run the following code in your SAS session: #;
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
%put %nrstr( filename packages "C:/SAS_PACKAGES"; );
%put %nrstr( %%include packages(SPFinit.sas); );
%put ;
%put %nrstr( %%installPackage(baseplus(1.17) macroarray(1.0) dfa(0.5) GSM) );
%put %nrstr( %%loadPackageS(GSM, baseplus(1.17), macroarray(1.0), dfa(0.5)) );
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
%put ##############################################################################################;
%put ;
options &options_tmp.;
@@ -731,8 +750,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/* in case the 'packages' fileref is multi-directory the first directory will be selected as a destination */
data _null_;
/* get the firstPackagesPath */
call symputX("firstPackagesPath", dequote(kscanx(pathname("packages"), 1, "()", "QS")) ,"L");
if "(" =: pathname("packages") then
/* get the firstPackagesPath */
call symputX("firstPackagesPath", dequote(kscanx(pathname("packages"), 1, "()", "QS")), "L");
else
call symputX("firstPackagesPath", pathname("packages"), "L");
run;
%if %superq(sourcePath)= %then
@@ -765,14 +787,51 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%mirrorEnd:
%put INFO: Source path is &sourcePath.;
%end;
%else
%do;
%let mirror=-1;
%let SPFinitMirror = &sourcePath.SPFinit.sas;
%end;
%local i;
%local i str;
/* standardise list of packages */
%let str = %qsysfunc(compress(%superq(packagesNames),[{(. _)}],kad));
%let str = %qsysfunc(translate(%superq(str),[[]],{()}));
%let str = %qsysfunc(transtrn(%superq(str),],%str(] )));
%let str = %qsysfunc(compbl(%superq(str)));
%let str = %qsysfunc(transtrn(%superq(str),%str([ ),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( [),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( ]),]));
%let str = %unquote(&str.);
%let packagesNames = %qsysfunc(translate(%superq(str),(),[]));
%if %length("%sysfunc(compress(%superq(str),[,k))") NE %length("%sysfunc(compress(%superq(str),],k))") %then
%do;
%put ERROR: Syntax error in list of packages!;
%put ERROR- %superq(packagesNames);
%goto packagesListError;
%end;
%put ;
%put INFO: Calling: &packagesNames.;
%do i = 1 %to %sysfunc(countw(&packagesNames., , S));
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
%local packageName packageSubDir;
%let packageName = %scan(&packagesNames., &i., , S);
%local packageName packageSubDir vers versA versB;
%put ;
/*%put ### %scan(&packagesNames., &i., , S) ###;*/
%let packageName = %scan(%scan(&packagesNames., &i., , S),1,{[()]});
%let versA = %scan(%scan(&packagesNames., &i., , S),2,{[()]});
%let versB = %scan(&version., &i., , S);
%let vers=;
%if %superq(versB) ne %then %let vers = &versB.;
%if %superq(versA) ne %then %let vers = &versA.;
%if -1 = &mirror %then /* ignore version when direct path is provided */
%do;
%let vers=;
%end;
%put ### &packageName.(&vers.) ###;
%put *** %lowcase(&packageName.) start *****************************************;
%local in out _IOFileref_;
data _null_; call symputX("_IOFileref_", put(MD5("%lowcase(&packageName.)"), hex7. -L), "L"); run;
@@ -785,6 +844,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%if %upcase(&packageName.) in (SPFINIT SASPACKAGEFRAMEWORK SASPACKAGESFRAMEWORK) %then
%do;
/* allows to install/download the framework file like any other package */
%if %superq(mirror) in (0 1) AND (%superq(vers) ne) %then
%do;
%let SPFinitMirror = https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/&vers./SPF/SPFinit.sas;
%end;
filename &in URL
"&SPFinitMirror."
recfm=N lrecl=1;
@@ -797,11 +861,11 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
%if 0 = %superq(mirror) %then
%do;
%let packageSubDir = %lowcase(&packageName.)/raw/main/;
%if %superq(version) ne %then
%if %superq(vers) ne %then
%do;
/*%let packageSubDir = %lowcase(&packageName.)/main/hist/&version./;*/
%let packageSubDir = %lowcase(&packageName.)/raw/&version./;
%let packageSubDir = %lowcase(&packageName.)/raw/&vers./;
%end;
%end;
filename &in URL "&sourcePath.&packageSubDir.%lowcase(&packageName.).zip"
@@ -878,6 +942,8 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/*-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-*/
%end;
%packagesListError:
options ls = &ls_tmp. ps = &ps_tmp.
&notes_tmp. &source_tmp.
&stimer_tmp. &fullstimer_tmp.
@@ -989,7 +1055,7 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/* Macro to list SAS packages in packages folder.
Version 20221001
Version 20221107
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1010,7 +1076,7 @@ des = 'Macro to install SAS package, version 20221001. Run %%installPackage() fo
/*+listPackages+*/
%macro listPackages()/secure PARMBUFF
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20221001.'
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20221107.'
;
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
%do;
@@ -1025,7 +1091,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 `20221001` #;
%put # Macro to list available SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -1175,7 +1241,7 @@ options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
/* Macro to generate SAS packages.
Version 20221001
Version 20221107
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -1212,7 +1278,7 @@ options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
default value 1 means "delete tests work" */
)/secure minoperator
/*** HELP END ***/
des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage() for help info.'
des = 'Macro to generate SAS packages, version 20221107. Run %generatePackage() for help info.'
;
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
%do;
@@ -1227,7 +1293,7 @@ des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage()
%put ### This is short help information for the `generatePackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to generate SAS packages, version `20221001` #;
%put # Macro to generate SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -1284,6 +1350,7 @@ des = 'Macro to generate SAS packages, version 20221001. Run %generatePackage()
%GOTO ENDofgeneratePackage;
%end;
%put --- generatePackage START ---;
%local zipReferrence filesWithCodes _DESCR_ _LIC_ _DUMMY_ _RC_ _PackageFileref_;
%let zipReferrence = _%sysfunc(datetime(), hex6.)_;
%let filesWithCodes = WORK._%sysfunc(datetime(), hex16.)_;
@@ -1439,7 +1506,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
put 'ERROR- ' R;
end;
else
rc = dosubl('title; options nonotes nosource ps=max ls=99 nodate nonumber nostimer;
rc = dosubl('title; options nonotes nosource ps=min ls=99 nodate nonumber nostimer;
data _null_;
length rq $ 64; put "Required:";
do rq = &packageRequired.;
@@ -1489,7 +1556,7 @@ filename &_LIC_. "&filesLocation./license.sas" lrecl = 1024;
put 'ERROR- ' R;
end;
else
rc = dosubl('title; options nonotes nosource ps=max ls=66 nodate nonumber nostimer;
rc = dosubl('title; options nonotes nosource ps=min ls=66 nodate nonumber nostimer;
data _null_;
length rq $ 64; put "ReqPackages:";
do rq = &packageReqPackages.;
@@ -1761,6 +1828,76 @@ options NOnotes NOsource;
proc sort data = &filesWithCodes.;
by order type file;
run;
/* quality check for EXEC and CLEAN types */
data _null_;
set &filesWithCodes. (where=(upcase(type) in ('EXEC' 'CLEAN'))) end=EOF;
if _N_ = 1 then
do;
declare hash EXEC(); /* store EXECs */
EXEC.defineKey('file');
EXEC.defineData('ne');
EXEC.defineDone();
declare hash CLEAN(); /* store CLEANs */
CLEAN.defineKey('file');
CLEAN.defineData('nc');
CLEAN.defineDone();
declare hash F(ordered:"A");
F.defineKey('file');
F.defineData('file');
F.defineDone();
declare hiter IF("F");
end;
F.replace();
if upcase(type) = 'EXEC' then
do;
e + 1;
if EXEC.find() then EXEC.add(key:file,data:1);
else EXEC.replace(key:file,data:ne+1);
end;
if upcase(type) = 'CLEAN' then
do;
c + 1;
if CLEAN.find() then CLEAN.add(key:file,data:1);
else CLEAN.replace(key:file,data:nc+1);
end;
if EOF then
do;
/* 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:';
do while(IF.next()=0);
ne = 0;
nc = 0;
df = EXEC.find();
df = CLEAN.find();
df = abs(ne - nc);
put "WARNING- File " file char36. "EXEC: " ne 3. +1 "CLEAN: " nc 3. +1 "diff: " df 3.;
end;
put "WARNING- ";
end;
/* 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: Aborting package generation!' ;
abort;
end;
end;
run;
/*
proc contents data = &filesWithCodes.;
run;
@@ -2794,7 +2931,7 @@ data _null_;
put ' end ; ';
%end;
put 'put "***"; put "* SAS package generated by generatePackage, version 20221001 *"; put "***";';
put 'put "***"; put "* SAS package generated by generatePackage, version 20221107 *"; put "***";';
put 'run; ' /;
@@ -3553,7 +3690,7 @@ title;
/*%put _local_;*/
%put NOTE: changing current folder to:;
%put NOTE: Changing current folder to:;
%put NOTE- *%sysfunc(DLGCDIR(%sysfunc(pathname(currdir))))*;
filename CURRDIR clear;
@@ -3573,6 +3710,7 @@ options &qlenmax_fstimer_tmp.;
%ENDofgeneratePackage:
%put --- generatePackage END ---;
%mend generatePackage;
@@ -3652,7 +3790,7 @@ TODO: (in Polish)
*/
)/secure
/*** HELP END ***/
des = 'Macro to load multiple SAS packages at one run, version 20221001. Run %loadPackages() for help info.'
des = 'Macro to load multiple SAS packages at one run, version 20221107. Run %loadPackages() for help info.'
parmbuff
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
@@ -3668,7 +3806,7 @@ parmbuff
%put ### This is short help information for the `loadPackageS` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro wrapper for the loadPackage macro, version `20221001` #;
%put # Macro wrapper for the loadPackage macro, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -3717,18 +3855,28 @@ parmbuff
%GOTO ENDofloadPackageS;
%end;
%local lengthOfsyspbuff numberOfPackagesNames i packageElement packageName packageVersion;
%local lengthOfsyspbuff numberOfPackagesNames i packageElement packageName packageVersion str;
%let lengthOfsyspbuff = %qsysfunc(length(&syspbuff.));
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), %str((._,)), KDA));
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str(,)));
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), {[(. _,)]}, KDA));
%let str = %qsysfunc(translate(%superq(packagesNames),[[ ]],{(,)}));
%let str = %qsysfunc(transtrn(%superq(str),],%str(] )));
%let str = %qsysfunc(compbl(%superq(str)));
%let str = %qsysfunc(transtrn(%superq(str),%str([ ),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( [),[));
%let str = %qsysfunc(transtrn(%superq(str),%str( ]),]));
%let str = %qsysfunc(translate(%superq(str),(),[]));
%let packagesNames = %unquote(&str.);
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str( )));
%put NOTE: List of packages to be loaded contains &numberOfPackagesNames. element(s).;
%put NOTE- The list is: &packagesNames..;
%put NOTE- ;
%do i = 1 %to &numberOfPackagesNames.;
%let packageElement = %qscan(&packagesNames., &i., %str(,) );
%let packageElement = %qscan(&packagesNames., &i., %str( ) );
%let packageName = %qscan(&packageElement., 1, %str(()));
%let packageVersion = %qscan(&packageElement., 2, %str(()));
%if %superq(packageVersion) = %then %let packageVersion = .;
@@ -3755,7 +3903,7 @@ parmbuff
hashing_file() function, SAS 9.4M6 */
)/secure
/*** HELP END ***/
des = 'Macro to verify SAS package with the hash digest, version 20221001. Run %verifyPackage() for help info.'
des = 'Macro to verify SAS package with the hash digest, version 20221107. Run %verifyPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -3770,7 +3918,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20221001. Run %
%put ### This is short help information for the `verifyPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to verify SAS package with it hash digest, version `20221001` #;
%put # Macro to verify SAS package with it hash digest, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -3941,7 +4089,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20221001. Run %
*/
)/secure
/*** HELP END ***/
des = 'Macro to preview content of a SAS package, version 20221001. Run %previewPackage() for help info.'
des = 'Macro to preview content of a SAS package, version 20221107. Run %previewPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -3956,7 +4104,7 @@ des = 'Macro to preview content of a SAS package, version 20221001. Run %preview
%put ### This is short help information for the `previewPackage` macro #;
%put #-------------------------------------------------------------------------------#;
%put # #;
%put # Macro to get previwe of a SAS packages, version `20221001` #;
%put # Macro to get previwe of a SAS packages, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -4083,7 +4231,7 @@ des = 'Macro to preview content of a SAS package, version 20221001. Run %preview
when empty the "packages" value is used */
)/secure
/*** HELP END ***/
des = 'Macro to list directories pointed by "packages" fileref, version 20221001. Run %extendPackagesFileref(HELP) for help info.'
des = 'Macro to list directories pointed by "packages" fileref, version 20221107. Run %extendPackagesFileref(HELP) for help info.'
;
%if %QUPCASE(&packages.) = HELP %then
@@ -4099,7 +4247,7 @@ des = 'Macro to list directories pointed by "packages" fileref, version 20221001
%put ### This is short help information for the `extendPackagesFileref` macro #;
%put #-----------------------------------------------------------------------------------------#;;
%put # #;
%put # Macro to list directories pointed by 'packages' fileref, version `20221001` #;
%put # Macro to list directories pointed by 'packages' fileref, version `20221107` #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;

View File

@@ -77,6 +77,8 @@ Kudos to all who inspired me to generate this package:
*Michal Ludwicki*,
*Quentin McMullen*.
Recording from the SAS Explore 2022 conference: [A BasePlus Package for SAS](https://communities.sas.com/t5/SAS-Explore-Presentations/A-BasePlus-Package-for-SAS/ta-p/838246 "A BasePlus Package for SAS") (September 27th-29th, 2022).
---
### BASIC EXAMPLES AND USECASES: ####################################################
@@ -3934,7 +3936,7 @@ The basic syntax is the following, the `<...>` means optional parameters:
## License ####################################################################
Copyright (c) 2020 Bartosz Jablonski
Copyright (c) since 2020 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