Compare commits

...

14 Commits

Author SHA1 Message Date
yabwon
5ecccacdce SAS Packages Framework, version 20201001
SAS Packages Framework, version 20201001
- `%installPackage` macro allows to install/download the framework file like any other package, e.g. `%installPackage(SPFinit)`,
- improvement in testing if HASHING_FILE function is available,
- documentation updated.
2020-10-01 20:02:26 +02:00
yabwon
b274d0dcda macroArray, version 0.5
spelling corrected
2020-09-18 23:09:49 +02:00
yabwon
3881f936ca SQLinDS, version 2.2 and macroArray, version 0.5
SQLinDS, version 2.2
- documentation updated, macroarray.md created

macroArray, version 0.5
- documentation updated, macroarray.md created
- the do_overs automatically unquote `betwee=` parameter
2020-09-15 13:03:31 +02:00
yabwon
d53f622776 SQLinDS, version 2.2
SQLinDS, version 2.2
- documentation updated, macroarray.md created
2020-09-15 13:02:37 +02:00
yabwon
8c584c8030 macroArray, version 0.5
macroArray, version 0.5
- documentation updated, macroarray.md created
- the do_overs automatically unquote `betwee=` parameter
2020-09-15 12:15:37 +02:00
yabwon
5c640cba21 macroArray, version 0.5
macroArray, version 0.5
- documentation updated
- the do_overs automatically unquote `betwee=` parameter
2020-09-15 11:28:54 +02:00
yabwon
73e8d10200 macroArray, version 0.5
macroArray, version 0.5
- documentation updated
- the do_overs automatically unquote `betwee=` parameter
2020-09-14 22:29:48 +02:00
yabwon
93904a03cb macroArray, version 0.5
macroArray, version 0.5
- documentation updated
- the do_overs automatically unquote `betwee=` parameter
2020-09-14 22:27:11 +02:00
yabwon
55aaa8748c version 20200911
SAS Packages Framework, version 20200911:
- New macros added: %loadPackageS() and %verifyPackage()
- %installPackage() allow to install multiple packages with in run
- %listPackages() updated
- %generatePackage() provides hash digest of the package zip file (for SAS 9.54M6 and later)
- Bug fixes
- New version of documentation and "getting started"

Packages recompiled with new version of SAS Packages Framework:
- BasePlus [0.62]
  - getVars() modified to handle "long" lists of variables
  - QuickSort functions added
- SQLinDS [2.2]
  - doc updated
- DFA (Dynamic Function Arrays) [0.2]
- macroArray [0.5]
  - new parameter `which=` added to the %do_over macro
  - the do_overs automatically unquote the `between=` parameter
  - doc updated
- dynMacroArray [0.2]
2020-09-14 22:19:13 +02:00
yabwon
63f849dd24 macroArray, version 0.5
macroArray, version 0.5
- documentation updated
- the do_overs automatically unquote `betwee=` parameter
2020-09-14 22:16:37 +02:00
yabwon
ef5864dc88 version 20200911
SAS Packages Framework, version 20200911:
- New macros added: %loadPackageS() and %verifyPackage()
- %installPackage() allow to install multiple packages with in run
- %listPackages() updated
- %generatePackage() provides hash digest of the package zip file (for SAS 9.54M6 and later)
- Bug fixes
- New version of documentation and "getting started"

Packages recompiled with new version of SAS Packages Framework:
- BasePlus [0.62]
- getVars() modified to handle "long" lists of variables
- QuickSort functions added
- SQLinDS [2.2]
- DFA (Dynamic Function Arrays) [0.2]
- macroArray [0.4]
-new parameter `which=` added to the %do_over macro
- dynMacroArray [0.2]
2020-09-14 17:08:07 +02:00
yabwon
c10851e9ef SQLinDS, version 2.2 2020-09-14 17:07:11 +02:00
yabwon
10994721b4 SQLinDS, version 2.2 2020-09-14 17:03:12 +02:00
yabwon
5461c587be SQLinDS, version 2.2 2020-09-14 17:02:42 +02:00
8 changed files with 1455 additions and 75 deletions

View File

@@ -6,7 +6,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 **`20200911`**.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20201001`**.
To get started with SAS Packages try this [**`Getting Started with SAS Packages`**](https://github.com/yabwon/SAS_PACKAGES/blob/master/SPF/Documentation/Getting_Started_with_SAS_Packages.pdf "Getting Started with SAS Packages") presentation (see the `./SPF/Documentation` directory).
@@ -56,30 +56,31 @@ To create your own package:
#### If you have any questions, suggestions, or ideas do not hesitate to contact me!
**Update**\[June 3rd, 2020\]**:** `%installPackage()` **macro is available**. The `%installPackage()` macro is embedded in the `loadpackage.sas` part of the framework.
**Update**\[June 3rd, 2020\]**:** `%installPackage()` **macro is available**. The `%installPackage()` macro is embedded in the `loadpackage.sas` part of the framework.
**Update**\[June 10th, 2020\]**:** To see help info about framework macros and their parameters just run: `%generatePackage()`, `%installPackage()`, `%helpPackage()`, `%loadPackage()`, and `%unloadPackage()` with empty parameter list.
**Update**\[July 30th, 2020\]**:** All components of SAS Packages Framework are now in one file `SPFinit.sas` (located in the `./SPF` directory). Documentation moved to `./SPF/Documentation` directory. Packages zip files moved to `./packages` directory.
**Update**\[June 10th, 2020\]**:** To see help info about framework macros and their parameters just run: `%generatePackage()`, `%installPackage()`, `%helpPackage()`, `%loadPackage()`, and `%unloadPackage()` with empty parameter list.
**Update**\[July 30th, 2020\]**:** All components of SAS Packages Framework are now in one file `SPFinit.sas` (located in the `./SPF` directory). Documentation moved to `./SPF/Documentation` directory. Packages zip files moved to `./packages` directory.
## Available packages:
Currently the following packages are available (see the `./packages` directory):
- **SQLinDS**\[2.1\], based on Mike Rhoads' article *Use the Full Power of SAS in Your Function-Style Macros*. The package allows to write SQL queries in the data step, e.g.
- **SQLinDS**\[2.2\], based on Mike Rhoads' article *Use the Full Power of SAS in Your Function-Style Macros*. The package allows to write SQL queries in the data step, e.g.
```
data class;
set %SQL(select * from sashelp.class order by age);
run;
data class;
set %SQL(select * from sashelp.class order by age);
run;
```
SHA256 digest for SQLinDS: 3EBC11A0890B6128DDB51643DC91F9DA1BDBF283535664540887FA7E7EA9744F
SHA256 digest for SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/sqlinds.md "Documentation for SQLinDS")
- **DFA** (Dynamic Function Arrays)\[0.2\], contains set of macros and FCMP functions which implement: a dynamically allocated array, a stack, a fifo queue, an ordered stack, and a priority queue, run `%helpPackage(DFA,createDFArray)` to find examples.
SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA
- **macroArray**\[0.4\], implementation of an array concept in a macrolanguage, e.g.
- **macroArray**\[0.5\], implementation of an array concept in a macrolanguage, e.g.
```
%array(ABC[17] (111:127), macarray=Y);
@@ -98,7 +99,9 @@ SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713
which = 1:H:2
);
```
SHA256 digest for macroArray: 5C9208ADD091E354794C24FA830F527D17CFC758C24CB77BF2154949059F7E6F
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
- **BasePlus**\[0.62\] adds a bunch of functionalities I am missing in BASE SAS, such as:
@@ -122,5 +125,4 @@ SHA256 digest for BasePlus: 278621A6D8BBBB791DEA4C215D4261F2CB8F8B76B1397F7FA9B2
SHA256 digest for dynMacroArray: 066186B94B2976167C797C6A6E6217E361E8DEB10F2AB81906E0A325E5243084
### ======

View File

@@ -42,13 +42,13 @@
- to unload, or
- to generate SAS packages.
Version 20200911.
Version 20201001.
See examples below.
A SAS package is a zip file containing a group of files
with SAS code (macros, functions, data steps generating
data, etc.) wrapped up together and %INCLUDEed by
a single load.sas file (also embedded inside the zip).
A SAS package is a zip file containing a group of files
with SAS code (macros, functions, data steps generating
data, etc.) wrapped up together and %INCLUDEed by
a single load.sas file (also embedded inside the zip).
*/
/*** HELP END ***/
@@ -81,7 +81,7 @@
*/
)/secure
/*** HELP END ***/
des = 'Macro to load SAS package, version 20200911. Run %loadPackage() for help info.'
des = 'Macro to load SAS package, version 20201001. Run %loadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -96,7 +96,7 @@ des = 'Macro to load SAS package, version 20200911. Run %loadPackage() for help
%put # This is short help information for the loadPackage macro #;
%put ###############################################################################;
%put # #;
%put # Macro to load SAS packages, version 20200911 #;
%put # Macro to load SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -248,7 +248,7 @@ des = 'Macro to load SAS package, version 20200911. Run %loadPackage() for help
*/
)/secure
/*** HELP END ***/
des = 'Macro to unload SAS package, version 20200911. Run %unloadPackage() for help info.'
des = 'Macro to unload SAS package, version 20201001. Run %unloadPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -263,7 +263,7 @@ des = 'Macro to unload SAS package, version 20200911. Run %unloadPackage() for h
%put # This is short help information for the unloadPackage macro #;
%put ###############################################################################;
%put # #;
%put # Macro to unload SAS packages, version 20200911 #;
%put # Macro to unload SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -383,7 +383,7 @@ des = 'Macro to unload SAS package, version 20200911. Run %unloadPackage() for h
*/
)/secure
/*** HELP END ***/
des = 'Macro to get help about SAS package, version 20200911. Run %helpPackage() for help info.'
des = 'Macro to get help about SAS package, version 20201001. Run %helpPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -398,7 +398,7 @@ des = 'Macro to get help about SAS package, version 20200911. Run %helpPackage()
%put # This is short help information for the helpPackage macro #;
%put ###############################################################################;
%put # #;
%put # Macro to get help about SAS packages, version 20200911 #;
%put # Macro to get help about SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -504,7 +504,7 @@ TODO:
- add MD5(&packageName.) value hash instead "package" word in filenames [DONE]
*/
/* Macros to install SAS packages, version 20200911 */
/* Macros to install SAS packages, version 20201001 */
/* 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
@@ -517,9 +517,10 @@ TODO:
, sourcePath = /* location of the package, e.g. "www.some.page/", mind the "/" at the end */
, replace = 1 /* 1 = replace if the package already exist, 0 = otherwise */
)
/secure
/secure
minoperator
/*** HELP END ***/
des = 'Macro to install SAS package, version 20200911. Run %%installPackage() for help info.'
des = 'Macro to install SAS package, version 20201001. Run %%installPackage() for help info.'
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
%do;
@@ -534,7 +535,7 @@ des = 'Macro to install SAS package, version 20200911. Run %%installPackage() fo
%put # This is short help information for the installPackage macro #;
%put #########################################################################################;
%put # #;
%put # Macro to install SAS packages, version 20200911 #;
%put # Macro to install SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -552,11 +553,15 @@ des = 'Macro to install SAS package, version 20200911. Run %%installPackage() fo
%put # Required and not null, default use case: #;
%put # %nrstr(%%installPackage(myPackage1 myPackage2)). #;
%put # If empty displays this help information. #;
%put # If the package name is "SPFinit" or "SASPackagesFramework" #;
%put # then the framework itself is downloaded. #;
%put # #;
%put # sourcePath= Location of the package, e.g. "www.some.web.page/" #;
%put # Mind the "/" at the end of the path! #;
%put # Current default location: #;
%put # Current default location for packages is: #;
%put # https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/ #;
%put # Current default location for the framework is: #;
%put # https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/SPF/ #;
%put # #;
%put # replace= With default value of 1 it causes existing package file #;
%put # to be replaceed by new downloaded file. #;
@@ -623,9 +628,21 @@ des = 'Macro to install SAS package, version 20200911. Run %%installPackage() fo
%let out = o%sysfunc(md5(&packageName.),hex7.);
/*options MSGLEVEL=i;*/
filename &in URL "&sourcePath.%lowcase(&packageName.).zip" recfm=N lrecl=1;
filename &out "%sysfunc(pathname(packages))/%lowcase(&packageName.).zip" recfm=N lrecl=1;
%if %upcase(&packageName.) in (SPFINIT SASPACKAGEFRAMEWORK SASPACKAGESFRAMEWORK) %then
%do;
/* allows to install/download the framework file like any other package */
filename &in URL
"https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/SPF/SPFinit.sas"
recfm=N lrecl=1;
filename &out
"%sysfunc(pathname(packages))/SPFinit.sas"
recfm=N lrecl=1;
%end;
%else
%do;
filename &in URL "&sourcePath.%lowcase(&packageName.).zip" recfm=N lrecl=1;
filename &out "%sysfunc(pathname(packages))/%lowcase(&packageName.).zip" recfm=N lrecl=1;
%end;
/*
filename in list;
filename out list;
@@ -810,7 +827,7 @@ des = 'Macro to install SAS package, version 20200911. Run %%installPackage() fo
/* Macro to list SAS packages in packages folder.
Version 20200911
Version 20201001
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -830,7 +847,7 @@ des = 'Macro to install SAS package, version 20200911. Run %%installPackage() fo
%macro listPackages()/PARMBUFF
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20200911.'
des = 'Macro to list SAS packages from `packages` fileref, type %listPackages(HELP) for help, version 20201001.'
;
%if %QUPCASE(&SYSPBUFF.) = %str(%(HELP%)) %then
%do;
@@ -845,7 +862,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 20200911 #;
%put # Macro to list available SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -975,7 +992,7 @@ options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
/* Macro to generate SAS packages.
Version 20200911
Version 20201001
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
@@ -998,7 +1015,7 @@ options ls = &ls_tmp. ps = &ps_tmp. &notes_tmp. &source_tmp.;
dependencies in loading */
)/secure
/*** HELP END ***/
des = 'Macro to generate SAS packages, version 20200911. Run %generatePackage() for help info.'
des = 'Macro to generate SAS packages, version 20201001. Run %generatePackage() for help info.'
;
%if (%superq(filesLocation) = ) OR (%qupcase(&filesLocation.) = HELP) %then
%do;
@@ -1013,7 +1030,7 @@ des = 'Macro to generate SAS packages, version 20200911. Run %generatePackage()
%put # This is short help information for the generatePackage macro #;
%put ###############################################################################;
%put # #;
%put # Macro to generate SAS packages, version 20200911 #;
%put # Macro to generate SAS packages, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -2177,7 +2194,7 @@ data _null_;
put " infile &_PackageFileref_.(description.sas) end = EOF; ";
put ' input; ';
put ' if upcase(strip(_infile_)) =: "DESCRIPTION END:" then printer = 0; ';
put ' if printer then put "*> " _infile_; ';
put ' if printer then put @1 _infile_; ';
put ' if upcase(strip(_infile_)) =: "DESCRIPTION START:" then printer = 1; ';
put ' end; ';
put ' else stop; ';
@@ -2215,7 +2232,7 @@ data _null_;
put ' end ; ';
%end;
put 'put "***"; put "* SAS package generated by generatePackage, version 20200911 *"; put "***";';
put 'put "***"; put "* SAS package generated by generatePackage, version 20201001 *"; put "***";';
put 'run; ' /;
@@ -2225,7 +2242,7 @@ data _null_;
put ' do until (EOF); ';
put " infile &_PackageFileref_.(license.sas) end = EOF; ";
put ' input; ';
put ' put "*> " _infile_; ';
put ' put @1 _infile_; ';
put ' end; ';
put ' else stop; ';
put 'run; ' /;
@@ -2288,11 +2305,11 @@ data _null_;
put ' call execute(" input; ");';
put ' call execute(" if upcase(strip(_infile_)) ';
put ' = ''/*** HELP END ***/'' then printer = 0; ");';
put ' call execute(" if printer then put ""*> "" _infile_; ");';
put ' call execute(" if printer then put @1 _infile_; ");';
put ' call execute(" if upcase(strip(_infile_)) ';
put ' = ''/*** HELP START ***/'' then printer = 1; ");';
put ' call execute(" end; ");';
put ' call execute(" put ""*> "" / ""*> ""; ");';
put ' call execute(" put "" "" / "" ""; ");';
put ' call execute(" stop; ");';
put ' call execute("run; ");';
put ' if lowcase(type) =: "data" then ';
@@ -2359,23 +2376,26 @@ filename &_LIC_. clear;
filename &zipReferrence. clear;
/* create hash SHA256 id */
filename &zipReferrence. "&filesLocation./%lowcase(&packageName.).zip";
filename &zipReferrence. list;
data _null_;
set sashelp.vfunc(keep=fncname);
where fncname = "HASHING_FILE";
call execute('
data the_SHA256_hash_id;
SHA256 = HASHING_FILE("SHA256", "&zipReferrence.", 4);
lable SHA256 = "The SHA256 hash digest for package &packageName.";
put SHA256=;
run;
proc print data = the_SHA256_hash_id noobs label;
run;
');
stop;
run;
filename &zipReferrence. clear;
%if %sysfunc(exist(sashelp.vfunc, VIEW)) %then
%do;
filename &zipReferrence. "&filesLocation./%lowcase(&packageName.).zip";
filename &zipReferrence. list;
data _null_;
set sashelp.vfunc(keep=fncname);
where fncname = "HASHING_FILE";
call execute('
data the_SHA256_hash_id;
SHA256 = HASHING_FILE("SHA256", "&zipReferrence.", 4);
lable SHA256 = "The SHA256 hash digest for package &packageName.:";
put SHA256=;
run;
proc print data = the_SHA256_hash_id noobs label;
run;
');
stop;
run;
filename &zipReferrence. clear;
%end;
/*+++++++++++++++++++++++*/
@@ -2709,7 +2729,7 @@ TODO: (in Polish)
*/
)/secure
/*** HELP END ***/
des = 'Macro to load multiple SAS packages at one run, version 20200911. Run %loadPackages() for help info.'
des = 'Macro to load multiple SAS packages at one run, version 20201001. Run %loadPackages() for help info.'
parmbuff
;
%if (%superq(packagesNames) = ) OR (%qupcase(&packagesNames.) = HELP) %then
@@ -2725,7 +2745,7 @@ parmbuff
%put # This is short help information for the loadPackageS macro #;
%put ###############################################################################;
%put # #;
%put # Macro wrapper for the loadPackage macro, version 20200911 #;
%put # Macro wrapper for the loadPackage macro, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -2780,7 +2800,7 @@ parmbuff
%let packagesNames = %qsysfunc(compress(%qsubstr(&syspbuff., 2, %eval(&lengthOfsyspbuff.-2)), %str((._,)), KDA));
%let numberOfPackagesNames = %qsysfunc(countw(&packagesNames., %str(,)));
%put NOTE: List op packages to be loaded contains &numberOfPackagesNames. element(s).;
%put NOTE: List of packages to be loaded contains &numberOfPackagesNames. element(s).;
%put NOTE- The list is: &packagesNames..;
%put NOTE- ;
@@ -2810,7 +2830,7 @@ parmbuff
hashing_file() function, SAS 9.4M6 */
)/secure
/*** HELP END ***/
des = 'Macro to verify SAS package with the hash digest, version 20200911. Run %verifyPackage() for help info.'
des = 'Macro to verify SAS package with the hash digest, version 20201001. Run %verifyPackage() for help info.'
;
%if (%superq(packageName) = ) OR (%qupcase(&packageName.) = HELP) %then
%do;
@@ -2825,7 +2845,7 @@ des = 'Macro to verify SAS package with the hash digest, version 20200911. Run %
%put # This is short help information for the verifyPackage macro #;
%put ###############################################################################;
%put # #;
%put # Macro to verify SAS package with it hash digest, version 20200911 #;
%put # Macro to verify SAS package with it hash digest, version 20201001 #;
%put # #;
%put # A SAS package is a zip file containing a group #;
%put # of SAS codes (macros, functions, data steps generating #;
@@ -2901,12 +2921,16 @@ des = 'Macro to verify SAS package with the hash digest, version 20200911. Run %
/* create hash SHA256 id *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
%local HASHING_FILE_exist;
%let HASHING_FILE_exist = 0;
data _null_;
set sashelp.vfunc(keep=fncname);
where fncname = "HASHING_FILE";
call symputX('HASHING_FILE_exist', 1, "L");
stop;
run;
%if %sysfunc(exist(sashelp.vfunc, VIEW)) %then
%do;
data _null_;
set sashelp.vfunc(keep=fncname);
where fncname = "HASHING_FILE";
call symputX('HASHING_FILE_exist', 1, "L");
stop;
run;
%end;
%if &HASHING_FILE_exist. = 1 %then
%do;

View File

@@ -4,7 +4,7 @@ To get started with SAS Packages try this [**`Getting Started with SAS Packages`
## Available packages:
Currently the following packages are available:
- **SQLinDS**\[2.1\], based on Mike Rhoads' article *Use the Full Power of SAS in Your Function-Style Macros*. The package allows to write SQL queries in the data step, e.g.
- **SQLinDS**\[2.2\], based on Mike Rhoads' article *Use the Full Power of SAS in Your Function-Style Macros*. The package allows to write SQL queries in the data step, e.g.
```
data class;
set %SQL(
@@ -16,7 +16,9 @@ data class;
WH = weight + height;
run;
```
SHA256 digest for SQLinDS: 3EBC11A0890B6128DDB51643DC91F9DA1BDBF283535664540887FA7E7EA9744F
SHA256 digest for SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
[Documentation for SQLinDS](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/sqlinds.md "Documentation for SQLinDS")
- **DFA** (Dynamic Function Arrays)\[0.2\], contains set of macros and FCMP functions which implement: a dynamically allocated array, a stack, a fifo queue, an ordered stack, and a priority queue, run `%helpPackage(DFA,createDFArray)` to find examples.
@@ -49,7 +51,7 @@ run;
SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA
- **macroArray**\[0.4\], implementation of an array concept in a macrolanguage, e.g.
- **macroArray**\[0.5\], implementation of an array concept in a macro language, e.g.
```
%array(ABC[17] (111:127), macarray=Y);
@@ -68,8 +70,9 @@ SHA256 digest for DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713
which = 1:H:2
);
```
SHA256 digest for macroArray: 5C9208ADD091E354794C24FA830F527D17CFC758C24CB77BF2154949059F7E6F
SHA256 digest for macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
- **BasePlus**\[0.62\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```

View File

@@ -1,3 +1,11 @@
/* 20200914 */
macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
/* 20200914 */
SQLinDS: DD5E319EB5AA29C7054EC428072F987E77C29D36874DED1AE5C62E4B300845EB
macroArray: 69F6CF496F921D0E21F3524FC7FD130B4B8290C1E0B9BB3ABEA212B734EBE8A1
/* 20200911 */
sqlindsdemo: CCA3CB51587E30D1A4338EAF732EF03E0922918AAA21C3ECF85CABE93CD2FB15
macroArray: 5C9208ADD091E354794C24FA830F527D17CFC758C24CB77BF2154949059F7E6F

1168
packages/macroarray.md Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

175
packages/sqlinds.md Normal file
View File

@@ -0,0 +1,175 @@
- [The SQLinDS package [ver. 2.2]](#sqlinds-package)
- [Content description](#content-description)
* [library `dsSQL`](#library-dssql)
* [`%dsSQL_inner()` macro](#dssql-inner-macro)
* [`%SQL()` macro](#dssql-inner-macro)
* [`dsSQL()` function](#dssql-function)
* [License](#license)
---
# The SQLinDS package [ver. 2.2] <a name="sqlinds-package"></a> ###############################################
The **SQLinDS** package is an implementation of
the *macro-function-sandwich* concept introduced in the
*"Use the Full Power of SAS in Your Function-Style Macros"*,
the article by *Mike Rhoads (Westat, Rockville)*.
Copy of the article is available at:
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
Package provides ability to *execute* SQL queries inside a data step, e.g.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data class;
set %SQL(select * from sashelp.class);
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See the help for the `%SQL()` macro to find more examples.
### Content ###################################################################
SQLinDS package contains the following components:
1. `%SQL()` macro - the main package macro available for the User
2. `dsSQL()` function (internal)
3. `%dsSQL_inner()` macro (internal)
4. Library `DSSQL` (created as a subdirectory of the `WORK` library)
---
Package contains:
1. libname dssql
2. macro dssql_inner
3. macro sql
4. function dssql
Required SAS Components:
*Base SAS Software*
*SAS package generated by generatePackage, version 20200911*
The SHA256 hash digest for package SQLinDS:
`B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D`
---
# Content description ############################################################################################
## >>> library `dsSQL`: <<< <a name="library-dssql"></a> ########################
The `dsSQL` library stores temporary views
generated during the `%SQL()` macro execution.
If possible a subdirectory of the `WORK` location is created, like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if not possible, then redirects to the `WORK` location, like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `%dsSQL_Inner()` macro: <<< <a name="dssql-inner-macro"></a> #############
**Internal** macro called by `dsSQL()` function.
The macro generates a uniquely named SQL view on the fly
which is then stored in the `dsSQL` library.
Recommended for *SAS 9.3* and higher.
---
## >>> `%SQL()` macro: <<< <a name="dssql-macro"></a> ###########################
The **main** macro which allows to use
SQL queries in the data step.
Recommended for *SAS 9.3* and higher.
Based on the article *"Use the Full Power of SAS in Your Function-Style Macros"*
by *Mike Rhoads* (Westat, Rockville), available at:
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
### SYNTAX: ###################################################################
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%sql(<nonempty sql querry code>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The sql query code is limited to *32000* bytes.
### EXAMPLES: #################################################################
**EXAMPLE 1**: simple SQL query
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data class_subset;
set %SQL(select name, sex, height from sashelp.class where age > 12);
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 2**: query with dataset options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data renamed;
set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2));
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3**: dictionaries in the data step
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data dictionary;
set %SQL(select * from dictionary.macros);
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
## >>> `dsSQL()` function: <<< <a name="dssql-function"></a> ####################
**Internal** function called by the `%SQL()` macro.
The function pass a query code from the `%SQL()`
macro to the `%dsSQL_Inner()` internal macro.
Recommended for *SAS 9.3* and higher.
### SYNTAX: ###################################################################
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
dsSQL(unique_index_2, query)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Arguments description**:
1. `unique_index_2` - *Numeric*, internal variable, a unique index for views.
2. `query` - *Character*, internal variable, contains query text.
---
## License ####################################################################
Copyright (c) 2012 Mike Rhoads
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---

Binary file not shown.