mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2025-12-10 10:44:35 +00:00
SAS Packages Framework, version 20241027
SAS Packages Framework, version 20241027
- new utility macro added (`%splitCodeForPackage()`)
- documentation and workshop materials updated
This commit is contained in:
@@ -16,7 +16,7 @@ Don't forget to **STAR** (:star:) the repository! :-)
|
||||
|
||||
### Current version:
|
||||
|
||||
**The latest version** of SPF is **`20241014`**.
|
||||
**The latest version** of SPF is **`20241027`**.
|
||||
|
||||
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).
|
||||
|
||||
@@ -163,6 +163,8 @@ The SAS Packages Framework [(short) documentation](https://github.com/yabwon/SAS
|
||||
|
||||
### Updates worth mentioning:
|
||||
|
||||
**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"))**.
|
||||
|
||||
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
when empty the "packages" value is used */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20241014. Run %extendPackagesFileref(HELP) for help info.'
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20241027. 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 20241014
|
||||
%put ### This is short help information for the `extendPackagesFileref` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20241014` #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Macro to generate SAS packages.
|
||||
|
||||
Version 20241014
|
||||
Version 20241027
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -43,7 +43,7 @@
|
||||
file name be created */
|
||||
)/ secure minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to generate SAS packages, version 20241014. Run %generatePackage() for help info.'
|
||||
des = 'Macro to generate SAS packages, version 20241027. Run %generatePackage() for help info.'
|
||||
;
|
||||
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
|
||||
%do;
|
||||
@@ -58,7 +58,7 @@ des = 'Macro to generate SAS packages, version 20241014. Run %generatePackage()
|
||||
%put ### This is short help information for the `generatePackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to generate SAS packages, version `20241014` #;
|
||||
%put # Macro to generate SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -871,7 +871,7 @@ title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_.";
|
||||
title8 "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */
|
||||
%end;
|
||||
|
||||
footnote1 "SAS Packages Framework, version 20241014";
|
||||
footnote1 "SAS Packages Framework, version 20241027";
|
||||
|
||||
proc print
|
||||
data = &filesWithCodes.(drop=base folderRef fileRef rc folderid _abort_ fileId additionalContent)
|
||||
@@ -1683,7 +1683,7 @@ data _null_;
|
||||
%end;
|
||||
put +(-1) '`.;''' /
|
||||
' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' /
|
||||
' !! '' %put with the SAS Packages Framework version 20241014.;''' /
|
||||
' !! '' %put with the SAS Packages Framework version 20241027.;''' /
|
||||
' !! '' %put ****************************************************************************;''' /
|
||||
' !! '' %GOTO theEndOfTheMacro;''' /
|
||||
' !! '' %end;''' ;
|
||||
@@ -1848,7 +1848,7 @@ data _null_;
|
||||
%end;
|
||||
put +(-1) '`.; '' !!' /
|
||||
''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !!' /
|
||||
''' %put with the SAS Packages Framework version 20241014.; '' !! ' /
|
||||
''' %put with the SAS Packages Framework version 20241027.; '' !! ' /
|
||||
''' %put ****************************************************************************; '' !! ' /
|
||||
''' %GOTO theEndOfTheMacro; '' !! ' /
|
||||
''' %end; '' !! ' /
|
||||
@@ -2655,7 +2655,7 @@ data _null_;
|
||||
%end;
|
||||
|
||||
put 'put " " / @3 "--------------------------------------------------------------------" / " ";'
|
||||
/ 'put @3 "*SAS package generated by SAS Package Framework, version `20241014`*";'
|
||||
/ 'put @3 "*SAS package generated by SAS Package Framework, version `20241027`*";'
|
||||
/ 'put " " / @3 "--------------------------------------------------------------------";';
|
||||
|
||||
put 'run; ' /;
|
||||
@@ -3693,7 +3693,7 @@ data &filesWithCodes.markdown;
|
||||
%end;
|
||||
|
||||
put " " / "--------------------------------------------------------------------" / " "
|
||||
/ "*SAS package generated by SAS Package Framework, version `20241014`*"
|
||||
/ "*SAS package generated by SAS Package Framework, version `20241027`*"
|
||||
/ " " / "--------------------------------------------------------------------" / " ";
|
||||
|
||||
put "# The `&packageName.` package content";
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to get help about SAS package, version 20241014. Run %helpPackage() for help info.'
|
||||
des = 'Macro to get help about SAS package, version 20241027. Run %helpPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -43,7 +43,7 @@ des = 'Macro to get help about SAS package, version 20241014. Run %helpPackage()
|
||||
%put ### This is short help information for the `helpPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get help about SAS packages, version `20241014` #;
|
||||
%put # Macro to get help about SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*+installPackage+*/
|
||||
/* Macros to install SAS packages, version 20241014 */
|
||||
/* Macros to install SAS packages, version 20241027 */
|
||||
/* 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
|
||||
@@ -23,7 +23,7 @@
|
||||
/secure
|
||||
minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to install SAS package, version 20241014. Run %%installPackage() for help info.'
|
||||
des = 'Macro to install SAS package, version 20241027. Run %%installPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
%do;
|
||||
@@ -38,7 +38,7 @@ des = 'Macro to install SAS package, version 20241014. Run %%installPackage() fo
|
||||
%put ### This is short help information for the `installPackage` macro #;
|
||||
%put #--------------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to install SAS packages, version `20241014` #;
|
||||
%put # Macro to install SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Macro to list SAS packages in packages folder.
|
||||
|
||||
Version 20241014
|
||||
Version 20241027
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
%macro listPackages()
|
||||
/secure PARMBUFF
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20241014.'
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20241027.'
|
||||
;
|
||||
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
||||
%do;
|
||||
@@ -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 `20241014` #;
|
||||
%put # Macro to list available SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load SAS package, version 20241014. Run %loadPackage() for help info.'
|
||||
des = 'Macro to load SAS package, version 20241027. Run %loadPackage() for help info.'
|
||||
minoperator
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
@@ -52,7 +52,7 @@ minoperator
|
||||
%put ### This is short help information for the `loadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to *load* SAS packages, version `20241014` #;
|
||||
%put # Macro to *load* SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
is provided in required version */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load additional content for a SAS package, version 20241014. Run %loadPackageAddCnt() for help info.'
|
||||
des = 'Macro to load additional content for a SAS package, version 20241027. Run %loadPackageAddCnt() for help info.'
|
||||
minoperator
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
@@ -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 `20241014` #;
|
||||
%put # Macro to *load* additional content for a SAS package, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -370,7 +370,5 @@ minoperator
|
||||
%ENDofloadPackageAddCnt:
|
||||
%mend loadPackageAddCnt;
|
||||
|
||||
|
||||
|
||||
|
||||
/**/
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20241014. Run %loadPackages() for help info.'
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20241027. 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 `20241014` #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to preview content of a SAS package, version 20241014. Run %previewPackage() for help info.'
|
||||
des = 'Macro to preview content of a SAS package, version 20241027. 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 20241014. Run %preview
|
||||
%put ### This is short help information for the `previewPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get preview of a SAS packages, version `20241014` #;
|
||||
%put # Macro to get preview of a SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
422
SPF/Macros/splitcodeforpackage.sas
Normal file
422
SPF/Macros/splitcodeforpackage.sas
Normal file
@@ -0,0 +1,422 @@
|
||||
/*+splitCodeForPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro splitCodeForPackage(
|
||||
codeFile /* a code file to split */
|
||||
,packagePath= /* location for results */
|
||||
,debug=0 /* technical parameter */
|
||||
,nobs=0 /* technical parameter */
|
||||
)
|
||||
/*** HELP START ***/
|
||||
/ des = 'Macro to split single code into multiple files for a SAS package, version 20241027. Run %splitCodeForPackage() for help info.'
|
||||
;
|
||||
/*%macro _();%mend _;*/
|
||||
%if (%superq(codeFile) = ) OR (%qupcase(&codeFile.) = 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 `splitCodeForPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Utility macro to *split* single file with SAS package code into multiple #;
|
||||
%put # files with separate snippets, version `20241027` #;
|
||||
%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(%%splitCodeForPackage())` macro takes a file with SAS code #;
|
||||
%put # snippets surrounded by `%str(/)*##$##-code-block-start-##$## <tag spec> *%str(/)` and #;
|
||||
%put # `%str(/)*##$##-code-block-end-##$## <tag spec> *%str(/)` tags and split that file into #;
|
||||
%put # multiple files and directories according to a tag specification. #;
|
||||
%put # #;
|
||||
%put # The `<tag spec>` is a list of pairs of the form: `type(object)` that #;
|
||||
%put # indicates how the file should be split. See example 1 below for details. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `codeFile=` *Required.* Name of a file containing code #;
|
||||
%put # that will be split. Required and not null. #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # - `packagePath=` *Required.* Location for package files after #;
|
||||
%put # splitting into separate files and directories. #;
|
||||
%put # If missing or not exist then `WORK` is uded. #;
|
||||
%put # #;
|
||||
%put # - `debug=` *Optional.* Turns on code printing for debugging. #;
|
||||
%put # #;
|
||||
%put # - `nobs=` *Optional.* Technical parameter with value `0`. #;
|
||||
%put # Do not change. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put ### Example 1 ###################################################################;
|
||||
%put # #;
|
||||
%put # Assume that the `myPackageCode.sas` file #;
|
||||
%put # is located in the `C:/lazy/` folder and #;
|
||||
%put # contain the following code and tags: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put ;
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 01_macro(abc) */ );
|
||||
%put %nrstr( %%macro abc(); );
|
||||
%put %nrstr( %%put I am "abc".; );
|
||||
%put %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( %%put I am "efg".; );
|
||||
%put %nrstr( %%mend efg; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 01_macro(efg) */ );
|
||||
%put ;
|
||||
%put %nrstr( proc FCMP outlib=work.f.p; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 02_functions(xyz) */ );
|
||||
%put %nrstr( function xyz(n); );
|
||||
%put %nrstr( return(n**2 + n + 1) );
|
||||
%put %nrstr( endfunc; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 02_functions(xyz) */ );
|
||||
%put %nrstr( quit; );
|
||||
%put ;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put # #;
|
||||
%put # and we want results in `C:/split/` folder, we run the following: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages;);
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%splitCodeForPackage%( );
|
||||
%put %nrstr( codeFile=C:/lazy/myPackageCode.sas );
|
||||
%put %nrstr( ,packagePath=C:/split/ %) );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put # #;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofsplitCodeForPackage;
|
||||
%end;
|
||||
|
||||
|
||||
%local options_tmp2 ;
|
||||
%let options_tmp2 = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options nomprint nosymbolgen nomlogic notes source ls=MAX ps=MAX msglevel=N ;
|
||||
|
||||
%let debug = %sysevalf(NOT(0=%superq(debug)));
|
||||
%if 1=&debug. %then
|
||||
%do;
|
||||
options mprint symbolgen mlogic source source2 msglevel=i;
|
||||
%end;
|
||||
|
||||
%put NOTE- --&SYSMACRONAME.-START--;
|
||||
%local rc;
|
||||
%let rc = %sysfunc(doSubL(%nrstr(
|
||||
options
|
||||
%sysfunc(ifc(1=&debug.
|
||||
,msglevel=I ls=max ps=64 notes mprint symbolgen mlogic source source2
|
||||
,msglevel=N ls=max ps=64 nonotes nomprint nosymbolgen nomlogic nosource nosource2
|
||||
))
|
||||
;;;;
|
||||
|
||||
options DLcreateDir;
|
||||
libname w "%sysfunc(pathname(WORK))/_splitCodeForPackage_";
|
||||
filename d "%sysfunc(pathname(WORK))/_splitCodeForPackage_/dummy";
|
||||
data _null_;
|
||||
file d;
|
||||
put "dummy";
|
||||
run;
|
||||
|
||||
data _null_;
|
||||
length codeFile $ 4096;
|
||||
codeFile = symget('codeFile');
|
||||
codeFile = dequote(codeFile);
|
||||
|
||||
if fileexist(codeFile) then
|
||||
do;
|
||||
codeFile = quote(strip(codeFile),"'");
|
||||
call symputX("codeFile",codeFile,"L");
|
||||
end;
|
||||
else
|
||||
do;
|
||||
put 'ERROR: File ' codeFile 'does not exist!';
|
||||
call symputX("codeFile",pathname('d'),"L");
|
||||
end;
|
||||
run;
|
||||
|
||||
options notes;
|
||||
filename source &codeFile.;
|
||||
filename source LIST;
|
||||
options nonotes;
|
||||
|
||||
data _null_;
|
||||
length packagePath work $ 4096;
|
||||
work = pathname('WORK');
|
||||
packagePath = coalescec(symget('packagePath'), work);
|
||||
rc = fileexist(packagePath);
|
||||
if NOT rc then packagePath = work;
|
||||
if rc = 1 then put "INFO: " @;
|
||||
else put "WARNING: " @;
|
||||
put packagePath=;
|
||||
call symputX('packagePath',packagePath,"L");
|
||||
run;
|
||||
|
||||
|
||||
data w.files;
|
||||
stop;
|
||||
run;
|
||||
|
||||
data _null_;
|
||||
if 1 = _N_ then
|
||||
do;
|
||||
declare hash H(ordered:"A");
|
||||
H.defineKey('token');
|
||||
H.defineData('token','start','end','lineNumber');
|
||||
H.defineDone();
|
||||
end;
|
||||
if 1 = _E_ then
|
||||
do;
|
||||
H.output(dataset:'w.files');
|
||||
end;
|
||||
|
||||
infile source END=_E_;
|
||||
lineNumberN+1;
|
||||
input;
|
||||
|
||||
length line $ 4096 lineNumber $ 256;
|
||||
line = left(lowcase(_infile_));
|
||||
block=scan(line,1," ");
|
||||
|
||||
if block in (
|
||||
'/*##$##-code-block-start-##$##'
|
||||
'/*##$##-code-block-end-##$##'
|
||||
);
|
||||
|
||||
if substr(block,20,1) = 's' then
|
||||
do; s=1; e=0; end;
|
||||
else
|
||||
do; s=0; e=1; end;
|
||||
|
||||
i=1;
|
||||
token=block;
|
||||
do while(i);
|
||||
i+1;
|
||||
token=scan(line,i," ");
|
||||
if token='*/' OR token=' ' then i=0;
|
||||
else
|
||||
do;
|
||||
start=0; end=0;
|
||||
if H.find() then
|
||||
do;
|
||||
start=s;
|
||||
end =e;
|
||||
lineNumber = cats(lineNumberN);
|
||||
end;
|
||||
else
|
||||
do;
|
||||
start+s;
|
||||
end +e;
|
||||
lineNumber = catx(",",lineNumber,lineNumberN);
|
||||
end;
|
||||
H.replace();
|
||||
/*putlog token= s= e= start= end=;*/
|
||||
end;
|
||||
end;
|
||||
run;
|
||||
|
||||
title;
|
||||
title1 "Attention!!! Not Matching Tags!";
|
||||
title2 "Verify following tags in file:";
|
||||
title3 &codeFile.;
|
||||
proc print data=w.files(where=(start NE end));
|
||||
run;
|
||||
title;
|
||||
|
||||
data w.files;
|
||||
set w.files end=_E_ nobs=nobs;
|
||||
where start=end;
|
||||
length dir $ 128 code $ 32 path $ 160;
|
||||
dir =coalescec(scan(token,1,'()'),'!BAD_DIRECTORY');
|
||||
code=coalescec(scan(token,2,'()'),'!BAD_CODE_FILE');
|
||||
if dir = '!BAD_DIRECTORY' or code = '!BAD_CODE_FILE' then
|
||||
put "WARNING: Bad directory or code file name!"
|
||||
/ "WARNING- Check tag: " token ;
|
||||
path=cats('/',dir,'/',code,'.sas'); /* .sas */
|
||||
run;
|
||||
|
||||
title;
|
||||
title1 "List of tags with value _ALL_ for 'dir' or 'code' variable.";
|
||||
title2 "Snippets tagged this way will be copied to multiple files.";
|
||||
proc print data=w.files(where=(dir = '_all_' OR code = '_all_'));
|
||||
run;
|
||||
title;
|
||||
|
||||
data w.files;
|
||||
if 0=nobs then
|
||||
put "WARNING: No tags found in the file";
|
||||
|
||||
set w.files end=_E_ nobs=nobs;
|
||||
where dir NE '_all_' AND code NE '_all_';
|
||||
n+1;
|
||||
if 1 = _E_ then
|
||||
call symputX('nobs',n,"L");
|
||||
run;
|
||||
|
||||
title;
|
||||
title "List of files";
|
||||
proc print data=w.files;
|
||||
run;
|
||||
title;
|
||||
|
||||
data _null_;
|
||||
set w.files;
|
||||
rc = libname("_",catx("/",symget('packagePath'),dir));
|
||||
rc = libname("_");
|
||||
run;
|
||||
|
||||
filename f DUMMY;
|
||||
data _null_;
|
||||
if 1 =_N_ then
|
||||
do;
|
||||
array paths[0:&nobs.] $ 128 _temporary_;
|
||||
array starts[0:&nobs.] _temporary_;
|
||||
array ends[0:&nobs.] _temporary_;
|
||||
array write[0:&nobs.] _temporary_;
|
||||
array firstLine[0:&nobs.] _temporary_;
|
||||
|
||||
declare hash H();
|
||||
H.defineKey('token');
|
||||
H.defineData('n');
|
||||
H.defineDone();
|
||||
|
||||
do until(_E_);
|
||||
set w.files end=_E_;
|
||||
paths[n]=path;
|
||||
starts[n]=start;
|
||||
ends[n]=end;
|
||||
write[n]=0;
|
||||
rc=H.add();
|
||||
firstLine[n]=1;
|
||||
end;
|
||||
_E_=.;
|
||||
length packagePath $ 4096;
|
||||
retain packagePath " ";
|
||||
packagePath=symget('packagePath');
|
||||
end;
|
||||
|
||||
infile source END=_E_;
|
||||
input;
|
||||
|
||||
length line /*lineToPrint*/ $ 4096;
|
||||
line = left(lowcase(_infile_));
|
||||
/*lineToPrint=_infile_;*/
|
||||
block=scan(line,1," ");
|
||||
|
||||
if block in (
|
||||
'/*##$##-code-block-start-##$##'
|
||||
'/*##$##-code-block-end-##$##'
|
||||
) then
|
||||
do;
|
||||
/********************************************************/
|
||||
if substr(block,20,1) = 's' then
|
||||
do; s=1; e=0; end;
|
||||
else
|
||||
do; s=0; e=1; end;
|
||||
|
||||
i=1;
|
||||
token=block;
|
||||
do while(i);
|
||||
i+1;
|
||||
token=scan(line,i," ");
|
||||
if token='*/' OR token=' ' then i=0; /* if it is the end of list - stop */
|
||||
else if token='_all_(_all_)' then /* if this is a snippet for ALL files in a package */
|
||||
do k=1 to &nobs.;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
else if scan(token,2,'()')='_all_' then /* if this is a snippet for ALL files in a type */
|
||||
do k=1 to &nobs.;
|
||||
if scan(token,1,'()')=scan(paths[k],1,'/\') then
|
||||
do;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
end;
|
||||
else if scan(token,1,'()')='_all_' then /* if this is a snippet for ALL files with the same name */
|
||||
do k=1 to &nobs.;
|
||||
if (scan(token,2,'()')!!'.sas')=scan(paths[k],2,'/\') then
|
||||
do;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
end;
|
||||
else /* all other "regular" cases */
|
||||
do;
|
||||
if 0=H.find() then
|
||||
do;
|
||||
starts[n]+ -s;
|
||||
ends[n] + -e;
|
||||
write[n] + (s-e);
|
||||
select;
|
||||
when(write[n]<0)
|
||||
putlog "ERROR: Wrong tags order for " token=;
|
||||
when(write[n]>1)
|
||||
do;
|
||||
putlog "WARNING: Doubled value for tag" token=;
|
||||
putlog "WARNING- detected in line " _N_;
|
||||
putlog "WARNING- Check also counterpart block.";
|
||||
end;
|
||||
otherwise;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
/********************************************************/
|
||||
end;
|
||||
else
|
||||
do j = 1 to hbound(write);
|
||||
if write[j]>0 then
|
||||
do;
|
||||
length fvariable $ 4096;
|
||||
fvariable=catx("/",packagePath,paths[j]);
|
||||
file f FILEVAR=fvariable MOD;
|
||||
/*
|
||||
lineToPrintLen=(lengthn(lineToPrint));
|
||||
if lineToPrintLen then
|
||||
put @1 lineToPrint $varying4096. lineToPrintLen;
|
||||
else put;
|
||||
*/
|
||||
if firstLine[j] then
|
||||
do;
|
||||
put '/* File generated with help of SAS Packages Framework, version 20241027. */';
|
||||
firstLine[j]=0;
|
||||
end;
|
||||
put _infile_;
|
||||
end;
|
||||
end;
|
||||
run;
|
||||
|
||||
filename f clear;
|
||||
libname w clear;
|
||||
)));
|
||||
%put NOTE- --&sysmacroname.-END--;
|
||||
options &options_tmp2.;
|
||||
%ENDofsplitCodeForPackage:
|
||||
%mend splitCodeForPackage;
|
||||
|
||||
|
||||
/**/
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to unload SAS package, version 20241014. Run %unloadPackage() for help info.'
|
||||
des = 'Macro to unload SAS package, version 20241027. 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 20241014. Run %unloadPackage() for h
|
||||
%put ### This is short help information for the `unloadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to unload SAS packages, version `20241014` #;
|
||||
%put # Macro to unload SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
hashing_file() function, SAS 9.4M6 */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20241014. Run %verifyPackage() for help info.'
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20241027. 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 20241014. Run %
|
||||
%put ### This is short help information for the `verifyPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20241014` #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
|
||||
108
SPF/SPFinit.md
108
SPF/SPFinit.md
@@ -11,6 +11,7 @@
|
||||
* [the `generatePackage` macro](#generatepackage)
|
||||
* [the `extendPackagesFileref` macro](#extendpackagesfileref)
|
||||
* [the `loadPackageAddCnt` macro](#loadpackageaddcnt)
|
||||
* [the `splitCodeForPackage` macro](#splitcodeforpackage)
|
||||
* [Some more examples](#some-more-examples)
|
||||
|
||||
---
|
||||
@@ -22,7 +23,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 **`20241014`**.
|
||||
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20241027`**.
|
||||
|
||||
**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).
|
||||
|
||||
@@ -40,7 +41,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 `20241014`
|
||||
Macro to install SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -154,7 +155,7 @@ filename packages "C:/SAS_PACKAGES";
|
||||
## This is short help information for the `helpPackage` macro <a name="helppackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to get help about SAS packages, version `20241014`
|
||||
Macro to get help about SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -230,7 +231,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 `20241014`
|
||||
Macro to *load* SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -386,7 +387,7 @@ If created, those macros are automatically deleted when the `%unloadPackage()` m
|
||||
## This is short help information for the `loadPackageS` macro <a name="loadpackages"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro wrapper for the loadPackage macro, version `20241014`
|
||||
Macro wrapper for the loadPackage macro, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -435,7 +436,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 `20241014`
|
||||
Macro to unload SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -500,7 +501,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 `20241014`
|
||||
Macro to list available SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -541,7 +542,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 `20241014`
|
||||
Macro to verify SAS package with it hash digest, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -595,7 +596,7 @@ filename packages "C:/SAS_PACKAGES"; %* set-up a directory for packages;
|
||||
## This is short help information for the `previewPackage` macro <a name="previewpackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to get preview of a SAS packages, version `20241014`
|
||||
Macro to get preview of a SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -662,7 +663,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 `20241014`
|
||||
Macro to generate SAS packages, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -877,7 +878,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 `20241014`
|
||||
Macro to list directories pointed by 'packages' fileref, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -917,7 +918,7 @@ filename packages ("D:/NEW_DIR" %extendPackagesFileref()); %* add new directory;
|
||||
## This is short help information for the `loadPackageAddCnt` macro <a name="loadpackageaddcnt"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Macro to load *additional content* for a SAS package, version `20241014`
|
||||
Macro to load *additional content* for a SAS package, version `20241027`
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -1003,6 +1004,89 @@ filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
%installPackage(SQLinDS) %* install the package from the Internet;
|
||||
%loadPackageAddCnt(SQLinDS) %* load additional content for the package;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
## This is short help information for the `splitCodeForPackage` macro <a name="splitcodeforpackage"></a>
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Utility macro to *split* single file with SAS package code into multiple
|
||||
files with separate snippets, version `20241027`
|
||||
|
||||
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 `%splitCodeForPackage()` macro takes a file with SAS code
|
||||
snippets surrounded by `/*##$##-code-block-start-##$## <tag spec> */` and
|
||||
`/*##$##-code-block-end-##$## <tag spec> */` tags and split that file into
|
||||
multiple files and directories according to a tag specification.
|
||||
|
||||
The `<tag spec>` is a list of pairs of the form: `type(object)` that
|
||||
indicates how the file should be split. See example 1 below for details.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
### Parameters:
|
||||
|
||||
1. `codeFile=` *Required.* Name of a file containing code
|
||||
that will be split. Required and not null.
|
||||
If empty displays this help information.
|
||||
|
||||
- `packagePath=` *Required.* Location for package files after
|
||||
splitting into separate files and directories.
|
||||
If missing or not exist then `WORK` is uded.
|
||||
|
||||
- `debug=` *Optional.* Turns on code printing for debugging.
|
||||
|
||||
- `nobs=` *Optional.* Technical parameter with value `0`.
|
||||
Do not change.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation`
|
||||
to learn more.
|
||||
|
||||
### Example 1 ##################################################################
|
||||
|
||||
Assume that the `myPackageCode.sas` file
|
||||
is located in the `C:/lazy/` folder and
|
||||
contain the following code and tags:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
|
||||
/*##$##-code-block-start-##$## 01_macro(abc) */
|
||||
%macro abc();
|
||||
%put I am "abc".;
|
||||
%mend abc;
|
||||
/*##$##-code-block-end-##$## 01_macro(abc) */
|
||||
|
||||
/*##$##-code-block-start-##$## 01_macro(efg) */
|
||||
%macro efg();
|
||||
%put I am "efg".;
|
||||
%mend efg;
|
||||
/*##$##-code-block-end-##$## 01_macro(efg) */
|
||||
|
||||
proc FCMP outlib=work.f.p;
|
||||
/*##$##-code-block-start-##$## 02_functions(xyz) */
|
||||
function xyz(n);
|
||||
return(n**2 + n + 1)
|
||||
endfunc;
|
||||
/*##$##-code-block-end-##$## 02_functions(xyz) */
|
||||
quit;
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
and we want results in `C:/split/` folder, we run the following:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
|
||||
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
|
||||
%include packages(SPFinit.sas); %* enable the framework;
|
||||
|
||||
%splitCodeForPackage(
|
||||
codeFile=C:/lazy/myPackageCode.sas
|
||||
,packagePath=C:/split/ )
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
## Some more examples <a name="some-more-examples"></a> #############################################################
|
||||
|
||||
482
SPF/SPFinit.sas
482
SPF/SPFinit.sas
@@ -42,7 +42,7 @@
|
||||
- to unload, or
|
||||
- to generate SAS packages.
|
||||
|
||||
Version 20241014.
|
||||
Version 20241027.
|
||||
See examples below.
|
||||
|
||||
A SAS package is a zip file containing a group of files
|
||||
@@ -91,7 +91,7 @@
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load SAS package, version 20241014. Run %loadPackage() for help info.'
|
||||
des = 'Macro to load SAS package, version 20241027. Run %loadPackage() for help info.'
|
||||
minoperator
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
@@ -107,7 +107,7 @@ minoperator
|
||||
%put ### This is short help information for the `loadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to *load* SAS packages, version `20241014` #;
|
||||
%put # Macro to *load* SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -372,7 +372,7 @@ minoperator
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to unload SAS package, version 20241014. Run %unloadPackage() for help info.'
|
||||
des = 'Macro to unload SAS package, version 20241027. Run %unloadPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -387,7 +387,7 @@ des = 'Macro to unload SAS package, version 20241014. Run %unloadPackage() for h
|
||||
%put ### This is short help information for the `unloadPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to unload SAS packages, version `20241014` #;
|
||||
%put # Macro to unload SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -538,7 +538,7 @@ des = 'Macro to unload SAS package, version 20241014. Run %unloadPackage() for h
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to get help about SAS package, version 20241014. Run %helpPackage() for help info.'
|
||||
des = 'Macro to get help about SAS package, version 20241027. Run %helpPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -553,7 +553,7 @@ des = 'Macro to get help about SAS package, version 20241014. Run %helpPackage()
|
||||
%put ### This is short help information for the `helpPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get help about SAS packages, version `20241014` #;
|
||||
%put # Macro to get help about SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -694,7 +694,7 @@ TODO:
|
||||
*/
|
||||
|
||||
/*+installPackage+*/
|
||||
/* Macros to install SAS packages, version 20241014 */
|
||||
/* Macros to install SAS packages, version 20241027 */
|
||||
/* 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
|
||||
@@ -718,7 +718,7 @@ TODO:
|
||||
/secure
|
||||
minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to install SAS package, version 20241014. Run %%installPackage() for help info.'
|
||||
des = 'Macro to install SAS package, version 20241027. Run %%installPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
%do;
|
||||
@@ -733,7 +733,7 @@ des = 'Macro to install SAS package, version 20241014. Run %%installPackage() fo
|
||||
%put ### This is short help information for the `installPackage` macro #;
|
||||
%put #--------------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to install SAS packages, version `20241014` #;
|
||||
%put # Macro to install SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -1266,7 +1266,7 @@ des = 'Macro to install SAS package, version 20241014. Run %%installPackage() fo
|
||||
|
||||
Macro to list SAS packages in packages folder.
|
||||
|
||||
Version 20241014
|
||||
Version 20241027
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -1286,7 +1286,7 @@ des = 'Macro to install SAS package, version 20241014. Run %%installPackage() fo
|
||||
|
||||
%macro listPackages()
|
||||
/secure PARMBUFF
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20241014.'
|
||||
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20241027.'
|
||||
;
|
||||
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
|
||||
%do;
|
||||
@@ -1301,7 +1301,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 `20241014` #;
|
||||
%put # Macro to list available SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -1452,7 +1452,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
|
||||
Macro to generate SAS packages.
|
||||
|
||||
Version 20241014
|
||||
Version 20241027
|
||||
|
||||
A SAS package is a zip file containing a group
|
||||
of SAS codes (macros, functions, data steps generating
|
||||
@@ -1492,7 +1492,7 @@ options ls = &ls_tmp. ps = &ps_tmp. ¬es_tmp. &source_tmp.;
|
||||
file name be created */
|
||||
)/ secure minoperator
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to generate SAS packages, version 20241014. Run %generatePackage() for help info.'
|
||||
des = 'Macro to generate SAS packages, version 20241027. Run %generatePackage() for help info.'
|
||||
;
|
||||
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
|
||||
%do;
|
||||
@@ -1507,7 +1507,7 @@ des = 'Macro to generate SAS packages, version 20241014. Run %generatePackage()
|
||||
%put ### This is short help information for the `generatePackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to generate SAS packages, version `20241014` #;
|
||||
%put # Macro to generate SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -2320,7 +2320,7 @@ title6 "MD5 hashed fileref of package lowcase name: &_PackageFileref_.";
|
||||
title8 "Required SAS packages: %qsysfunc(compress(%superq(packageReqPackages),%str(%'%")))" ; /* " */
|
||||
%end;
|
||||
|
||||
footnote1 "SAS Packages Framework, version 20241014";
|
||||
footnote1 "SAS Packages Framework, version 20241027";
|
||||
|
||||
proc print
|
||||
data = &filesWithCodes.(drop=base folderRef fileRef rc folderid _abort_ fileId additionalContent)
|
||||
@@ -3132,7 +3132,7 @@ data _null_;
|
||||
%end;
|
||||
put +(-1) '`.;''' /
|
||||
' !! '' %put The macro generated: '' !! put(dtCASLudf, E8601DT19.-L) !! ";"' /
|
||||
' !! '' %put with the SAS Packages Framework version 20241014.;''' /
|
||||
' !! '' %put with the SAS Packages Framework version 20241027.;''' /
|
||||
' !! '' %put ****************************************************************************;''' /
|
||||
' !! '' %GOTO theEndOfTheMacro;''' /
|
||||
' !! '' %end;''' ;
|
||||
@@ -3297,7 +3297,7 @@ data _null_;
|
||||
%end;
|
||||
put +(-1) '`.; '' !!' /
|
||||
''' %put The macro generated: ''' " !! put(dtIML, E8601DT19.-L) !! " '''; '' !!' /
|
||||
''' %put with the SAS Packages Framework version 20241014.; '' !! ' /
|
||||
''' %put with the SAS Packages Framework version 20241027.; '' !! ' /
|
||||
''' %put ****************************************************************************; '' !! ' /
|
||||
''' %GOTO theEndOfTheMacro; '' !! ' /
|
||||
''' %end; '' !! ' /
|
||||
@@ -4104,7 +4104,7 @@ data _null_;
|
||||
%end;
|
||||
|
||||
put 'put " " / @3 "--------------------------------------------------------------------" / " ";'
|
||||
/ 'put @3 "*SAS package generated by SAS Package Framework, version `20241014`*";'
|
||||
/ 'put @3 "*SAS package generated by SAS Package Framework, version `20241027`*";'
|
||||
/ 'put " " / @3 "--------------------------------------------------------------------";';
|
||||
|
||||
put 'run; ' /;
|
||||
@@ -5142,7 +5142,7 @@ data &filesWithCodes.markdown;
|
||||
%end;
|
||||
|
||||
put " " / "--------------------------------------------------------------------" / " "
|
||||
/ "*SAS package generated by SAS Package Framework, version `20241014`*"
|
||||
/ "*SAS package generated by SAS Package Framework, version `20241027`*"
|
||||
/ " " / "--------------------------------------------------------------------" / " ";
|
||||
|
||||
put "# The `&packageName.` package content";
|
||||
@@ -5420,7 +5420,7 @@ TODO: (in Polish)
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20241014. Run %loadPackages() for help info.'
|
||||
des = 'Macro to load multiple SAS packages at one run, version 20241027. Run %loadPackages() for help info.'
|
||||
parmbuff
|
||||
;
|
||||
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
|
||||
@@ -5436,7 +5436,7 @@ parmbuff
|
||||
%put ### This is short help information for the `loadPackageS` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20241014` #;
|
||||
%put # Macro wrapper for the loadPackage macro, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -5533,7 +5533,7 @@ parmbuff
|
||||
hashing_file() function, SAS 9.4M6 */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20241014. Run %verifyPackage() for help info.'
|
||||
des = 'Macro to verify SAS package with the hash digest, version 20241027. Run %verifyPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -5548,7 +5548,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20241014. Run %
|
||||
%put ### This is short help information for the `verifyPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20241014` #;
|
||||
%put # Macro to verify SAS package with it hash digest, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -5728,7 +5728,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20241014. Run %
|
||||
*/
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to preview content of a SAS package, version 20241014. Run %previewPackage() for help info.'
|
||||
des = 'Macro to preview content of a SAS package, version 20241027. Run %previewPackage() for help info.'
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
%do;
|
||||
@@ -5743,7 +5743,7 @@ des = 'Macro to preview content of a SAS package, version 20241014. Run %preview
|
||||
%put ### This is short help information for the `previewPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Macro to get preview of a SAS packages, version `20241014` #;
|
||||
%put # Macro to get preview of a SAS packages, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -5873,7 +5873,7 @@ des = 'Macro to preview content of a SAS package, version 20241014. Run %preview
|
||||
when empty the "packages" value is used */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20241014. Run %extendPackagesFileref(HELP) for help info.'
|
||||
des = 'Macro to list directories pointed by "packages" fileref, version 20241027. Run %extendPackagesFileref(HELP) for help info.'
|
||||
;
|
||||
|
||||
%if %QUPCASE(&packages.) = HELP %then
|
||||
@@ -5889,7 +5889,7 @@ des = 'Macro to list directories pointed by "packages" fileref, version 20241014
|
||||
%put ### This is short help information for the `extendPackagesFileref` macro #;
|
||||
%put #-----------------------------------------------------------------------------------------#;;
|
||||
%put # #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20241014` #;
|
||||
%put # Macro to list directories pointed by 'packages' fileref, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -5990,7 +5990,7 @@ filename packages list;
|
||||
is provided in required version */
|
||||
)/secure
|
||||
/*** HELP END ***/
|
||||
des = 'Macro to load additional content for a SAS package, version 20241014. Run %loadPackageAddCnt() for help info.'
|
||||
des = 'Macro to load additional content for a SAS package, version 20241027. Run %loadPackageAddCnt() for help info.'
|
||||
minoperator
|
||||
;
|
||||
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
|
||||
@@ -6006,7 +6006,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 `20241014` #;
|
||||
%put # Macro to *load* additional content for a SAS package, version `20241027` #;
|
||||
%put # #;
|
||||
%put # A SAS package is a zip file containing a group #;
|
||||
%put # of SAS codes (macros, functions, data steps generating #;
|
||||
@@ -6341,7 +6341,427 @@ minoperator
|
||||
%ENDofloadPackageAddCnt:
|
||||
%mend loadPackageAddCnt;
|
||||
|
||||
/**/
|
||||
|
||||
/*+splitCodeForPackage+*/
|
||||
/*** HELP START ***/
|
||||
|
||||
%macro splitCodeForPackage(
|
||||
codeFile /* a code file to split */
|
||||
,packagePath= /* location for results */
|
||||
,debug=0 /* technical parameter */
|
||||
,nobs=0 /* technical parameter */
|
||||
)
|
||||
/*** HELP START ***/
|
||||
/ des = 'Utility macro to split "one big" code into multiple files for a SAS package, version 20241027. Run %splitCodeForPackage() for help info.'
|
||||
;
|
||||
/*%macro _();%mend _;*/
|
||||
%if (%superq(codeFile) = ) OR (%qupcase(&codeFile.) = 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 `splitCodeForPackage` macro #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Utility macro to *split* single file with SAS package code into multiple #;
|
||||
%put # files with separate snippets, version `20241027` #;
|
||||
%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(%%splitCodeForPackage())` macro takes a file with SAS code #;
|
||||
%put # snippets surrounded by `%str(/)*##$##-code-block-start-##$## <tag spec> *%str(/)` and #;
|
||||
%put # `%str(/)*##$##-code-block-end-##$## <tag spec> *%str(/)` tags and split that file into #;
|
||||
%put # multiple files and directories according to a tag specification. #;
|
||||
%put # #;
|
||||
%put # The `<tag spec>` is a list of pairs of the form: `type(object)` that #;
|
||||
%put # indicates how the file should be split. See example 1 below for details. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put #### Parameters: #;
|
||||
%put # #;
|
||||
%put # 1. `codeFile=` *Required.* Name of a file containing code #;
|
||||
%put # that will be split. Required and not null. #;
|
||||
%put # If empty displays this help information. #;
|
||||
%put # #;
|
||||
%put # - `packagePath=` *Required.* Location for package files after #;
|
||||
%put # splitting into separate files and directories. #;
|
||||
%put # If missing or not exist then `WORK` is uded. #;
|
||||
%put # #;
|
||||
%put # - `debug=` *Optional.* Turns on code printing for debugging. #;
|
||||
%put # #;
|
||||
%put # - `nobs=` *Optional.* Technical parameter with value `0`. #;
|
||||
%put # Do not change. #;
|
||||
%put # #;
|
||||
%put #-------------------------------------------------------------------------------#;
|
||||
%put # #;
|
||||
%put # Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/main/SPF/Documentation` #;
|
||||
%put # to learn more. #;
|
||||
%put # #;
|
||||
%put ### Example 1 ###################################################################;
|
||||
%put # #;
|
||||
%put # Assume that the `myPackageCode.sas` file #;
|
||||
%put # is located in the `C:/lazy/` folder and #;
|
||||
%put # contain the following code and tags: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put ;
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 01_macro(abc) */ );
|
||||
%put %nrstr( %%macro abc(); );
|
||||
%put %nrstr( %%put I am "abc".; );
|
||||
%put %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( %%put I am "efg".; );
|
||||
%put %nrstr( %%mend efg; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 01_macro(efg) */ );
|
||||
%put ;
|
||||
%put %nrstr( proc FCMP outlib=work.f.p; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-start-##$## 02_functions(xyz) */ );
|
||||
%put %nrstr( function xyz(n); );
|
||||
%put %nrstr( return(n**2 + n + 1) );
|
||||
%put %nrstr( endfunc; );
|
||||
%put %nrstr( /)%nrstr(*##$##-code-block-end-##$## 02_functions(xyz) */ );
|
||||
%put %nrstr( quit; );
|
||||
%put ;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put # #;
|
||||
%put # and we want results in `C:/split/` folder, we run the following: #;
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas;
|
||||
%put %nrstr( filename packages "C:/SAS_PACKAGES"; %%* setup a directory for packages;);
|
||||
%put %nrstr( %%include packages(SPFinit.sas); %%* enable the framework; );
|
||||
%put ;
|
||||
%put %nrstr( %%splitCodeForPackage%( );
|
||||
%put %nrstr( codeFile=C:/lazy/myPackageCode.sas );
|
||||
%put %nrstr( ,packagePath=C:/split/ %) );
|
||||
%put ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
|
||||
%put # #;
|
||||
%put #################################################################################;
|
||||
%put ;
|
||||
options &options_tmp.;
|
||||
%GOTO ENDofsplitCodeForPackage;
|
||||
%end;
|
||||
|
||||
|
||||
%local options_tmp2 ;
|
||||
%let options_tmp2 = ls=%sysfunc(getoption(ls)) ps=%sysfunc(getoption(ps))
|
||||
%sysfunc(getoption(notes)) %sysfunc(getoption(source))
|
||||
msglevel=%sysfunc(getoption(msglevel))
|
||||
;
|
||||
options nomprint nosymbolgen nomlogic notes source ls=MAX ps=MAX msglevel=N ;
|
||||
|
||||
%let debug = %sysevalf(NOT(0=%superq(debug)));
|
||||
%if 1=&debug. %then
|
||||
%do;
|
||||
options mprint symbolgen mlogic source source2 msglevel=i;
|
||||
%end;
|
||||
|
||||
%put NOTE- --&SYSMACRONAME.-START--;
|
||||
%local rc;
|
||||
%let rc = %sysfunc(doSubL(%nrstr(
|
||||
options
|
||||
%sysfunc(ifc(1=&debug.
|
||||
,msglevel=I ls=max ps=64 notes mprint symbolgen mlogic source source2
|
||||
,msglevel=N ls=max ps=64 nonotes nomprint nosymbolgen nomlogic nosource nosource2
|
||||
))
|
||||
;;;;
|
||||
|
||||
options DLcreateDir;
|
||||
libname w "%sysfunc(pathname(WORK))/_splitCodeForPackage_";
|
||||
filename d "%sysfunc(pathname(WORK))/_splitCodeForPackage_/dummy";
|
||||
data _null_;
|
||||
file d;
|
||||
put "dummy";
|
||||
run;
|
||||
|
||||
data _null_;
|
||||
length codeFile $ 4096;
|
||||
codeFile = symget('codeFile');
|
||||
codeFile = dequote(codeFile);
|
||||
|
||||
if fileexist(codeFile) then
|
||||
do;
|
||||
codeFile = quote(strip(codeFile),"'");
|
||||
call symputX("codeFile",codeFile,"L");
|
||||
end;
|
||||
else
|
||||
do;
|
||||
put 'ERROR: File ' codeFile 'does not exist!';
|
||||
call symputX("codeFile",pathname('d'),"L");
|
||||
end;
|
||||
run;
|
||||
|
||||
options notes;
|
||||
filename source &codeFile.;
|
||||
filename source LIST;
|
||||
options nonotes;
|
||||
|
||||
data _null_;
|
||||
length packagePath work $ 4096;
|
||||
work = pathname('WORK');
|
||||
packagePath = coalescec(symget('packagePath'), work);
|
||||
rc = fileexist(packagePath);
|
||||
if NOT rc then packagePath = work;
|
||||
if rc = 1 then put "INFO: " @;
|
||||
else put "WARNING: " @;
|
||||
put packagePath=;
|
||||
call symputX('packagePath',packagePath,"L");
|
||||
run;
|
||||
|
||||
|
||||
data w.files;
|
||||
stop;
|
||||
run;
|
||||
|
||||
data _null_;
|
||||
if 1 = _N_ then
|
||||
do;
|
||||
declare hash H(ordered:"A");
|
||||
H.defineKey('token');
|
||||
H.defineData('token','start','end','lineNumber');
|
||||
H.defineDone();
|
||||
end;
|
||||
if 1 = _E_ then
|
||||
do;
|
||||
H.output(dataset:'w.files');
|
||||
end;
|
||||
|
||||
infile source END=_E_;
|
||||
lineNumberN+1;
|
||||
input;
|
||||
|
||||
length line $ 4096 lineNumber $ 256;
|
||||
line = left(lowcase(_infile_));
|
||||
block=scan(line,1," ");
|
||||
|
||||
if block in (
|
||||
'/*##$##-code-block-start-##$##'
|
||||
'/*##$##-code-block-end-##$##'
|
||||
);
|
||||
|
||||
if substr(block,20,1) = 's' then
|
||||
do; s=1; e=0; end;
|
||||
else
|
||||
do; s=0; e=1; end;
|
||||
|
||||
i=1;
|
||||
token=block;
|
||||
do while(i);
|
||||
i+1;
|
||||
token=scan(line,i," ");
|
||||
if token='*/' OR token=' ' then i=0;
|
||||
else
|
||||
do;
|
||||
start=0; end=0;
|
||||
if H.find() then
|
||||
do;
|
||||
start=s;
|
||||
end =e;
|
||||
lineNumber = cats(lineNumberN);
|
||||
end;
|
||||
else
|
||||
do;
|
||||
start+s;
|
||||
end +e;
|
||||
lineNumber = catx(",",lineNumber,lineNumberN);
|
||||
end;
|
||||
H.replace();
|
||||
/*putlog token= s= e= start= end=;*/
|
||||
end;
|
||||
end;
|
||||
run;
|
||||
|
||||
title;
|
||||
title1 "Attention!!! Not Matching Tags!";
|
||||
title2 "Verify following tags in file:";
|
||||
title3 &codeFile.;
|
||||
proc print data=w.files(where=(start NE end));
|
||||
run;
|
||||
title;
|
||||
|
||||
data w.files;
|
||||
set w.files end=_E_ nobs=nobs;
|
||||
where start=end;
|
||||
length dir $ 128 code $ 32 path $ 160;
|
||||
dir =coalescec(scan(token,1,'()'),'!BAD_DIRECTORY');
|
||||
code=coalescec(scan(token,2,'()'),'!BAD_CODE_FILE');
|
||||
if dir = '!BAD_DIRECTORY' or code = '!BAD_CODE_FILE' then
|
||||
put "WARNING: Bad directory or code file name!"
|
||||
/ "WARNING- Check tag: " token ;
|
||||
path=cats('/',dir,'/',code,'.sas'); /* .sas */
|
||||
run;
|
||||
|
||||
title;
|
||||
title1 "List of tags with value _ALL_ for 'dir' or 'code' variable.";
|
||||
title2 "Snippets tagged this way will be copied to multiple files.";
|
||||
proc print data=w.files(where=(dir = '_all_' OR code = '_all_'));
|
||||
run;
|
||||
title;
|
||||
|
||||
data w.files;
|
||||
if 0=nobs then
|
||||
put "WARNING: No tags found in the file";
|
||||
|
||||
set w.files end=_E_ nobs=nobs;
|
||||
where dir NE '_all_' AND code NE '_all_';
|
||||
n+1;
|
||||
if 1 = _E_ then
|
||||
call symputX('nobs',n,"L");
|
||||
run;
|
||||
|
||||
title;
|
||||
title "List of files";
|
||||
proc print data=w.files;
|
||||
run;
|
||||
title;
|
||||
|
||||
data _null_;
|
||||
set w.files;
|
||||
rc = libname("_",catx("/",symget('packagePath'),dir));
|
||||
rc = libname("_");
|
||||
run;
|
||||
|
||||
filename f DUMMY;
|
||||
data _null_;
|
||||
if 1 =_N_ then
|
||||
do;
|
||||
array paths[0:&nobs.] $ 128 _temporary_;
|
||||
array starts[0:&nobs.] _temporary_;
|
||||
array ends[0:&nobs.] _temporary_;
|
||||
array write[0:&nobs.] _temporary_;
|
||||
array firstLine[0:&nobs.] _temporary_;
|
||||
|
||||
declare hash H();
|
||||
H.defineKey('token');
|
||||
H.defineData('n');
|
||||
H.defineDone();
|
||||
|
||||
do until(_E_);
|
||||
set w.files end=_E_;
|
||||
paths[n]=path;
|
||||
starts[n]=start;
|
||||
ends[n]=end;
|
||||
write[n]=0;
|
||||
rc=H.add();
|
||||
firstLine[n]=1;
|
||||
end;
|
||||
_E_=.;
|
||||
length packagePath $ 4096;
|
||||
retain packagePath " ";
|
||||
packagePath=symget('packagePath');
|
||||
end;
|
||||
|
||||
infile source END=_E_;
|
||||
input;
|
||||
|
||||
length line /*lineToPrint*/ $ 4096;
|
||||
line = left(lowcase(_infile_));
|
||||
/*lineToPrint=_infile_;*/
|
||||
block=scan(line,1," ");
|
||||
|
||||
if block in (
|
||||
'/*##$##-code-block-start-##$##'
|
||||
'/*##$##-code-block-end-##$##'
|
||||
) then
|
||||
do;
|
||||
/********************************************************/
|
||||
if substr(block,20,1) = 's' then
|
||||
do; s=1; e=0; end;
|
||||
else
|
||||
do; s=0; e=1; end;
|
||||
|
||||
i=1;
|
||||
token=block;
|
||||
do while(i);
|
||||
i+1;
|
||||
token=scan(line,i," ");
|
||||
if token='*/' OR token=' ' then i=0; /* if it is the end of list - stop */
|
||||
else if token='_all_(_all_)' then /* if this is a snippet for ALL files in a package */
|
||||
do k=1 to &nobs.;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
else if scan(token,2,'()')='_all_' then /* if this is a snippet for ALL files in a type */
|
||||
do k=1 to &nobs.;
|
||||
if scan(token,1,'()')=scan(paths[k],1,'/\') then
|
||||
do;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
end;
|
||||
else if scan(token,1,'()')='_all_' then /* if this is a snippet for ALL files with the same name */
|
||||
do k=1 to &nobs.;
|
||||
if (scan(token,2,'()')!!'.sas')=scan(paths[k],2,'/\') then
|
||||
do;
|
||||
starts[k]+ -s;
|
||||
ends[k] + -e;
|
||||
write[k] + (s-e);
|
||||
end;
|
||||
end;
|
||||
else /* all other "regular" cases */
|
||||
do;
|
||||
if 0=H.find() then
|
||||
do;
|
||||
starts[n]+ -s;
|
||||
ends[n] + -e;
|
||||
write[n] + (s-e);
|
||||
select;
|
||||
when(write[n]<0)
|
||||
putlog "ERROR: Wrong tags order for " token=;
|
||||
when(write[n]>1)
|
||||
do;
|
||||
putlog "WARNING: Doubled value for tag" token=;
|
||||
putlog "WARNING- detected in line " _N_;
|
||||
putlog "WARNING- Check also counterpart block.";
|
||||
end;
|
||||
otherwise;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
/********************************************************/
|
||||
end;
|
||||
else
|
||||
do j = 1 to hbound(write);
|
||||
if write[j]>0 then
|
||||
do;
|
||||
length fvariable $ 4096;
|
||||
fvariable=catx("/",packagePath,paths[j]);
|
||||
file f FILEVAR=fvariable MOD;
|
||||
/*
|
||||
lineToPrintLen=(lengthn(lineToPrint));
|
||||
if lineToPrintLen then
|
||||
put @1 lineToPrint $varying4096. lineToPrintLen;
|
||||
else put;
|
||||
*/
|
||||
if firstLine[j] then
|
||||
do;
|
||||
put '/* File generated with help of SAS Packages Framework, version 20241027. */';
|
||||
firstLine[j]=0;
|
||||
end;
|
||||
put _infile_;
|
||||
end;
|
||||
end;
|
||||
run;
|
||||
|
||||
filename f clear;
|
||||
libname w clear;
|
||||
)));
|
||||
%put NOTE- --&sysmacroname.-END--;
|
||||
options &options_tmp2.;
|
||||
%ENDofsplitCodeForPackage:
|
||||
%mend splitCodeForPackage;
|
||||
|
||||
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user