Compare commits

...

33 Commits

Author SHA1 Message Date
yabwon
b373917770 SAS Packages Framework, version 20201010
**SAS Packages Framework**, version 20201010:
- Improvement in testing facility for the framework.
- Change in SAS components testing, missing component issues a *warning* instead of *error*.
- Documentation updated, `SPFinit.md` file added.
- Minor bug fixes.

Packages recompiled with new version of SAS Packages Framework:
- `SQLinDS` (version 2.2)
- `macroArray` (version 0.5)
- `DFA` (version 0.2)
- `BasePlus` (version 0.7)
  - documentation updated
  - new macro `%symdelGlobal()` added
- `dynMacroArray` (version 0.2)
2020-10-10 19:26:49 +02:00
yabwon
e7d94ad030 BasePlus, version 0.7
BasePlus, version 0.7:
- documentation updated
- new macro `%symdelGlobal()` added
2020-10-03 22:58:08 +02:00
yabwon
cf2ab0a7e7 BasePlus, version 0.7
BasePlus, version 0.7:
- documentation updated
- new macro `%symdelGlobal()` added
2020-10-03 22:54:35 +02:00
yabwon
b113b47869 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-03 20:04:15 +02:00
yabwon
a9ae379b59 Update README.md 2020-10-03 18:38:59 +02:00
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
yabwon
e97c8e31ad 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.1]
- DFA (Dynamic Function Arrays) [0.2]
- macroArray [0.4]
-new parameter `which=` added to the %do_over macro
- dynMacroArray [0.2]
2020-09-11 13:54:04 +02:00
yabwon
16d55d7dcb 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.1]
- DFA (Dynamic Function Arrays) [0.2]
- macroArray [0.4]
  -new parameter `which=` added to the %do_over macro
- dynMacroArray [0.2]
2020-09-11 13:51:19 +02:00
yabwon
c54ef20fac Getting Started with SAS Packages
macroArray, version 0.4
2020-09-08 20:29:30 +02:00
yabwon
be2af5883a macroArray, version 0.4 2020-09-08 20:28:15 +02:00
yabwon
b867ed4309 Getting Started with SAS Packages
*macroArray* version 0.4
2020-09-07 10:26:35 +02:00
yabwon
6a53bbe50a macroArray version 0.4 2020-09-07 10:24:55 +02:00
yabwon
3e44e6b8ae macroArray v.0.4
New parameter added to the %do_over macro.

The `which=` is a _SPACE_ separated list of indexes which should be used, possible special characters are `H` and `L` which means high and low bound of an array, list could be set with colons(:) in form of start:end:by (no spaces between!), if by is omitted the default is 1. If possible use `1:5` rather `1 2 3 4 5` since the firs works faster.
2020-09-07 10:07:42 +02:00
yabwon
f3f7a3896a version 20200827 2020-08-27 21:07:15 +02:00
yabwon
7491d42378 version 20200827
version 20200827,
-improvement in the testing part of the framework code
2020-08-27 21:06:04 +02:00
yabwon
16a20907af BasePlus version 0.62
bugfixes in sorting functions [experimental]
2020-08-19 16:41:16 +02:00
yabwon
f3107f0db3 BasePlus version 0.61
- getVars() modified to handle "long" lists of variables
- first iteration of QuickSort functions added [still experimental]
2020-08-18 12:27:08 +02:00
yabwon
0ca3eac3c9 BasePlus version 0.6
- getVars() modified to handle "long" lists of variables
 - first iteration of QuickSort functions added [still experimental]
2020-08-18 12:13:27 +02:00
yabwon
4eac2a0fea Merge branch 'master' of https://github.com/yabwon/SAS_PACKAGES 2020-08-15 13:18:06 +02:00
yabwon
ad81e0cb0e version 20200815
version 20200815, changes:
- Type PROTO added in the `%genaratePackge()` macro. Functions generated by Proc Proto in `externC functionName;` and `externCend;` blocks are available.
- Bug fix in the `%listPackages()` macro.
- Documentation updated.
2020-08-15 13:17:57 +02:00
15 changed files with 5021 additions and 530 deletions

View File

@@ -1,4 +1,4 @@
# SAS_PACKAGES - a SAS Packages Repository
# SAS_PACKAGES - a SAS Packages Framework and Repository
## Intro:
@@ -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 `20200811`.
In this repository we are presenting the **SAS Packages Framework** which allows to develop and use SAS packages. The latest version of SPF is **`20201010`**.
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,39 +56,55 @@ 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: D76B85EFF129678B45233FB397A2BDB8D23F234013BD821D55141CA18DD5589E
[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.
- **macroArray**\[0.3\], implementation of an array concept in a macrolanguage, e.g.
SHA256 digest for DFA: 43AE8BB0FC7D2121AABDD8DB8AD2C3F226C7D2699CAACC171FCB72B75D9141FA
- **macroArray**\[0.5\], implementation of an array concept in a macrolanguage, e.g.
```
%array(ABC[17] (111:127), macarray=Y);
%macro test();
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%mend;
%test()
%let %ABC(13,i) = 99999; /* i = insert */
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%let %ABC(13,i) = 999; /* i = insert */
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%do_over(ABC, phrase=%nrstr(
%put &_i_.%) %ABC(&_i_.);
),
which = 1:H:2
);
```
SHA256 digest for macroArray: 085A0F3D544EAF01378BB6C6B4F429123F8BFEEFC76013D1B05DFADFEE3FA661
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
- **BasePlus**\[0.7\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -102,7 +118,12 @@ format x bool.;
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
```
SHA256 digest for BasePlus: 54232DA5E253EB58E49A09DD0DF244F433B61983D921E27F2E4FFB1EA73A5C6D
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/baseplus.md "Documentation for BasePlus")
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
SHA256 digest for dynMacroArray: 281D9493564A8185B858D9525AA7D9D5343E42414AAB1D8A00AE85AB80882661
### ======

446
SPF/SPFinit.md Normal file
View File

@@ -0,0 +1,446 @@
## This is short help information for the `installPackage` macro
--------------------------------------------------------------------------------------------
Macro to install SAS packages, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and embedded inside the zip.
The `%installPackage()` macro installs the package zip
in the packages folder. The process of installation is equivalent with
manual downloading the package zip file into the packages folder.
--------------------------------------------------------------------------------------------
### Parameters:
1. `packagesNames` Space separated list of packages names _without_
the zip extension, e.g. myPackage1 myPackage2,
Required and not null, default use case:
`%installPackage(myPackage1 myPackage2)`.
If empty displays this help information.
If the package name is *SPFinit* or *SASPackagesFramework*
then the framework itself is downloaded.
- `sourcePath=` Location of the package, e.g. "www.some.web.page/"
Mind the "/" at the end of the path!
Current default location for packages is:
`https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/packages/`
Current default location for the framework is:
`https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/master/SPF/`
- `replace=` With default value of `1` it causes existing package file
to be replaceed by new downloaded file.
--------------------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation` to learn more.
### Example ################################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS) %* install the package from the Internet;
%helpPackage(SQLinDS) %* get help about the package;
%loadPackage(SQLinDS) %* load the package content into the SAS session;
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `helpPackage` macro
-------------------------------------------------------------------------------
Macro to get help about SAS packages, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and provided with
a single `help.sas` file (also embedded inside the zip).
The `%helpPackage()` macro prints in the SAS log help
information about the package provided by the developer.
-------------------------------------------------------------------------------
### Parameters:
1. `packageName` *Required.* Name of a package, e.g. myPackage,
Required and not null, default use case:
`%loadPackage(myPackage).`
If empty displays this help information.
2. `helpKeyword` *Optional.* A phrase to search in help,
- when empty prints description,
- "*" means prints all help,
- "license" prints the license.
- `path=` *Optional.* Location of a package. By default it
looks for location of the **packages** fileref, i.e.
`%sysfunc(pathname(packages))`
- `options=` *Optional.* Possible options for ZIP filename,
default value: `LOWCASE_MEMNAME`
- `source2=` *Optional.* Option to print out details about
what is loaded, null by default.
- `zip=` Standard package is zip (lowcase),
e.g. `%loadPackage(PiPackage)`.
If the zip is not available use a folder.
Unpack data to "pipackage.disk" folder
and use loadPackage in the following form:
`%loadPackage(PiPackage, zip=disk, options=)`
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
## Example ####################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS) %* install the package from the Internet;
%helpPackage(SQLinDS) %* get help about the package;
%loadPackage(SQLinDS) %* load the package content into the SAS session;
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `loadPackage` macro
-------------------------------------------------------------------------------
Macro to *load* SAS packages, version `20201010`
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 `%loadPackage()` macro loads package content, i.e. macros,
functions, formats, etc., from the zip into the SAS session.
-------------------------------------------------------------------------------
### Parameters:
1. `packageName` *Required.* Name of a package, e.g. myPackage,
Required and not null, default use case:
`%loadPackage(myPackage).`
If empty displays this help information.
- `path=` *Optional.* Location of a package. By default it
looks for location of the **packages** fileref, i.e.
`%sysfunc(pathname(packages))`
- `options=` *Optional.* Possible options for ZIP filename,
default value: `LOWCASE_MEMNAME`
- `source2=` *Optional.* Option to print out details about
what is loaded, null by default.
- `requiredVersion=` *Optional.* Option to test if the loaded
package is provided in required version,
default value: `.`
- `lazyData=` *Optional.* A list of names of lazy datasets to be
loaded. If not null datasets from the list are loaded
instead of the package.
An asterisk (*) means *load all lazy datasets*.
- `zip=` Standard package is zip (lowcase),
e.g. `%loadPackage(PiPackage)`.
If the zip is not available use a folder.
Unpack data to "pipackage.disk" folder
and use loadPackage in the following form:
`%loadPackage(PiPackage, zip=disk, options=)`
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
## Example ####################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS) %* install the package from the Internet;
%helpPackage(SQLinDS) %* get help about the package;
%loadPackage(SQLinDS) %* load the package content into the SAS session;
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `loadPackageS` macro
-------------------------------------------------------------------------------
Macro wrapper for the loadPackage macro, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and embedded inside the zip.
The `%loadPackageS()` allows to load multiple packages at one time,
*ONLY* from the *ZIP* with *DEFAULT OPTIONS*, into the SAS session.
### Parameters:
1. `packagesNames` A comma separated list of packages names,
e.g. myPackage, myPackage1, myPackage2, myPackage3
Required and not null, default use case:
`%loadPackageS(myPackage1, myPackage2, myPackage3)`.
Package version, in brackets behind a package name, can
be provided, example is the following:
`%loadPackageS(myPackage1(1.7), myPackage2(4.2))`.
If empty displays this help information.
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
### Example ###################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS DFA) %* install packages from the Internet;
%loadPackageS(SQLinDS, DFA) %* load packags content into the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `unloadPackage` macro
-------------------------------------------------------------------------------
Macro to unload SAS packages, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and provided with
a single `unload.sas` file (also embedded inside the zip).
The `%unloadPackage()` macro clears the package content
from the SAS session.
-------------------------------------------------------------------------------
### Parameters:
1. `packageName` *Required.* Name of a package, e.g. myPackage,
Required and not null, default use case:
`%loadPackage(myPackage).`
If empty displays this help information.
- `path=` *Optional.* Location of a package. By default it
looks for location of the **packages** fileref, i.e.
`%sysfunc(pathname(packages))`
- `options=` *Optional.* Possible options for ZIP filename,
default value: `LOWCASE_MEMNAME`
- `source2=` *Optional.* Option to print out details about
what is loaded, null by default.
- `zip=` Standard package is zip (lowcase),
e.g. `%loadPackage(PiPackage)`.
If the zip is not available use a folder.
Unpack data to "pipackage.disk" folder
and use loadPackage in the following form:
`%loadPackage(PiPackage, zip=disk, options=)`
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
### Example ###################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS) %* install the package from the Internet;
%helpPackage(SQLinDS) %* get help about the package;
%loadPackage(SQLinDS) %* load the package content into the SAS session;
%unloadPackage(SQLinDS) %* unload the package content from the SAS session;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `listPackages` macro
-----------------------------------------------------------------------------------------
Macro to list available SAS packages, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and embedded inside the zip.
The `%listPackages()` macro lists packages available
in the packages folder. List is printed inthe SAS Log.
### Parameters:
NO PARAMETERS
When used as: `%listPackages(HELP)` it displays this help information.
-----------------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
### Example #############################################################################
Enabling the SAS Package Framework
from the local directory and listing
available packages.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* setup a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%listPackages() %* list available packages;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### This is short help information for the `verifyPackage` macro
-------------------------------------------------------------------------------
Macro to verify SAS package with it hash digest, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and embedded inside the zip.
The `%verifyPackage()` macro generate package SHA256 hash
and compares it with the one provided by the user.
*Minimum SAS version required for the process is 9.4M6.*
### Parameters:
1. `packageName` Name of a package, e.g. myPackage,
Required and not null, default use case:
`%loadPackage(myPackage)`.
If empty displays this help information.
- `hash=` A value of the package `SHA256` hash.
Provided by the user.
- `path=` Location of a package. By default it looks for
location of the "packages" fileref, i.e.
`%sysfunc(pathname(packages))`
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to learn more.
### Example ###################################################################
Enabling the SAS Package Framework
from the local directory and installing & loading
the SQLinDS package from the Internet.
Assume that the `SPFinit.sas` file
is located in the "C:/SAS_PACKAGES/" folder.
Run the following code in your SAS session:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
filename packages "C:/SAS_PACKAGES"; %* set-up a directory for packages;
%include packages(SPFinit.sas); %* enable the framework;
%installPackage(SQLinDS) %* install the package from the Internet;
%verifPackage(SQLinDS, %* verify the package with provided hash;
hash=HDA478ANJ3HKHRY327FGE88HF89VH89HFFFV73GCV98RF390VB4)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## This is short help information for the `generatePackage` macro
-------------------------------------------------------------------------------
Macro to generate SAS packages, version `20201010`
A SAS package is a zip file containing a group
of SAS codes (macros, functions, data steps generating
data, etc.) wrapped up together and embedded inside the zip.
The `%generatePackage()` macro generates SAS packages.
It wraps-up the package content, i.e. macros, functions, formats, etc.,
into the zip file and generate all metadata content required by other
macros from the SAS Packages Framework.
-------------------------------------------------------------------------------
Visit: `https://github.com/yabwon/SAS_PACKAGES/tree/master/SPF/Documentation`
to read about the details of package generation process.
### Parameters:
1. `filesLocation=` Location of package files, example value:
`%sysfunc(pathname(work))/packagename`.
Default use case:
`%generatePackage(filesLocation=/path/to/packagename)`
If empty displays this help information.
- `testPackage=` Indicator if tests should be executed.
Default value: `Y`, means "execute tests"
- `packages=` Location of other packages for testing
if there are dependencies in loading the package.
-------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,9 @@ 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,6 +18,11 @@ data class;
WH = weight + height;
run;
```
SHA256 digest for SQLinDS: D76B85EFF129678B45233FB397A2BDB8D23F234013BD821D55141CA18DD5589E
[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.
```
@@ -44,23 +51,36 @@ data _null_;
end;
run;
```
SHA256 digest for DFA: 43AE8BB0FC7D2121AABDD8DB8AD2C3F226C7D2699CAACC171FCB72B75D9141FA
- **macroArray**\[0.3\], 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);
%macro test();
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%mend;
%test()
%let %ABC(13,i) = 99999; /* i = insert */
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%let %ABC(13,i) = 999; /* i = insert */
%do i = 1 %to 17;
%put &i.) %ABC(&i.);
%end;
%do_over(ABC, phrase=%nrstr(
%put &_i_.%) %ABC(&_i_.);
),
which = 1:H:2
);
```
SHA256 digest for macroArray: 085A0F3D544EAF01378BB6C6B4F429123F8BFEEFC76013D1B05DFADFEE3FA661
- **BasePlus**\[0.53\] adds a bunch of functionalities I am missing in BASE SAS, such as:
[Documentation for macroArray](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/macroarray.md "Documentation for macroArray")
---
- **BasePlus**\[0.7\] adds a bunch of functionalities I am missing in BASE SAS, such as:
```
call arrMissToRight(myArray);
call arrFillMiss(17, myArray);
@@ -74,6 +94,14 @@ format x bool.;
%put %getVars(sashelp.class, pattern = ght$, sep = +, varRange = _numeric_);
```
SHA256 digest for BasePlus: 54232DA5E253EB58E49A09DD0DF244F433B61983D921E27F2E4FFB1EA73A5C6D
[Documentation for BasePlus](https://github.com/yabwon/SAS_PACKAGES/blob/master/packages/baseplus.md "Documentation for BasePlus")
---
- **dynMacroArray**\[0.2\], set of macros (wrappers for a hash table) emulating dynamic array in the data step (macro predecessor of DFA)
SHA256 digest for dynMacroArray: 281D9493564A8185B858D9525AA7D9D5343E42414AAB1D8A00AE85AB80882661
---

View File

@@ -0,0 +1,33 @@
/* 20201010 */
SQLinDS: D76B85EFF129678B45233FB397A2BDB8D23F234013BD821D55141CA18DD5589E
DFA: 43AE8BB0FC7D2121AABDD8DB8AD2C3F226C7D2699CAACC171FCB72B75D9141FA
macroArray: 085A0F3D544EAF01378BB6C6B4F429123F8BFEEFC76013D1B05DFADFEE3FA661
BasePlus: 54232DA5E253EB58E49A09DD0DF244F433B61983D921E27F2E4FFB1EA73A5C6D
dynMacroArray: 281D9493564A8185B858D9525AA7D9D5343E42414AAB1D8A00AE85AB80882661
/* 20201007 */
BasePlus: 884BAD527DE77A9AF4325053BF42B3B2FCD3DB1239B63D70B1198064095E1A6D
DFA: 57944FF5ABC7A9879C402412DA0C18C38206301930DC834BC7DD3E968E283D1E
dynMacroArray: 20B27D2CACCC17DE9AB70F7AA7105FF1B29397584538632CAE167A687ACD859A
macroArray: F2AF51F9271B4AF5366DCC4E6403407393F245561B98A89C0F1699A6BCA84772
SQLinDS: AE2093A1D28F93FA665B4174FC38C0487C489D2B281FE398FF18CA738D841155
/* 20201003 */
BasePlus: 66E966489F4C183CA75FC32D3AF581FEC20FC9C5FF0C36E4DDC5A14BBDA82EAB
/* 20200914 */
macroArray: 53C248E1DE3268946C9CEC7E77BC222F652FBB006D9317BE36B86410DA31AE35
SQLinDS: B280D0B72DB77001ADAAE9C1612B67AD30C2C672371B27F1ACB12016C7A1363D
/* 20200914 */
SQLinDS: DD5E319EB5AA29C7054EC428072F987E77C29D36874DED1AE5C62E4B300845EB
macroArray: 69F6CF496F921D0E21F3524FC7FD130B4B8290C1E0B9BB3ABEA212B734EBE8A1
/* 20200911 */
sqlindsdemo: CCA3CB51587E30D1A4338EAF732EF03E0922918AAA21C3ECF85CABE93CD2FB15
macroArray: 5C9208ADD091E354794C24FA830F527D17CFC758C24CB77BF2154949059F7E6F
BasePlus: 278621A6D8BBBB791DEA4C215D4261F2CB8F8B76B1397F7FA9B2E4219E77CB5A
SQLinDS: 3EBC11A0890B6128DDB51643DC91F9DA1BDBF283535664540887FA7E7EA9744F
dynMacroArray: 066186B94B2976167C797C6A6E6217E361E8DEB10F2AB81906E0A325E5243084
DFA: BB8768E977D62429368CFF2E5338A6553C35C998AEC09AF24088BA713BB54DDA

2156
packages/baseplus.md Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

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:
`D76B85EFF129678B45233FB397A2BDB8D23F234013BD821D55141CA18DD5589E`
---
# 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.