The SQLinDS package [ver. 2.3.1]

The SQLinDS package [ver. 2.3.1]

Package regenerated with SAS Packages Framework, version 20251122. No functional changes, documentation cleaned up.
This commit is contained in:
Bart Jablonski
2025-11-22 13:18:59 +01:00
parent bb1cd6cdc3
commit 64e0daa157
5 changed files with 393 additions and 61 deletions

View File

@@ -7,10 +7,10 @@ The **SQLinDS** package is based on Mike Rhoads' article [*Use the Full Power of
The package allows to write SQL queries in the data step, e.g. The package allows to write SQL queries in the data step, e.g.
```sas ```sas
data class; data class;
set %SQL(select * from sashelp.class order by age); set %SQL(select name, age from sashelp.class order by age);
run; run;
``` ```
SHA256 digest for the latest version of `SQLinDS`: F*3C010734B76CA7459C4D35087C899121011CD4AA2932B56335FF11A805C8EF8D SHA256 digest for the latest version of `SQLinDS`: F*606A24A2A6B06DAAD2D443FA9A9819D9564235A5CD8599FD15586F1EFFCB41BC
[**Documentation for SQLinDS**](./sqlinds.md "Documentation for SQLinDS") [**Documentation for SQLinDS**](./sqlinds.md "Documentation for SQLinDS")

259
hist/2.3.1/sqlinds.md Normal file
View File

@@ -0,0 +1,259 @@
# Documentation for the `SQLinDS` package.
----------------------------------------------------------------
*SQL queries in Data Step*
----------------------------------------------------------------
### Version information:
- Package: SQLinDS
- Version: 2.3.1
- Generated: 2025-11-22T12:47:32
- Author(s): Mike Rhoads (RhoadsM1@Westat.com), contributor Bartosz Jablonski
- Maintainer(s): Bartosz Jablonski (yabwon@gmail.com)
- License: MIT
- File SHA256: `F*606A24A2A6B06DAAD2D443FA9A9819D9564235A5CD8599FD15586F1EFFCB41BC` for this version
- Content SHA256: `C*4CCCF31DA9D94E0EE2DA612724D395056B7BA07CB593C93947835BB8319B33EB` for this version
---
# The `SQLinDS` package, version: `2.3.1`;
---
### The SQLinDS package [ver. 2.3.1]
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)*.
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)
Copy of the article can also be found in *additional content* directory.
Package provides ability to *execute* SQL queries inside a data step, e.g.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data class;
set %SQL(select name, age 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)
5. Optional KMF-abbreviations `sqlinds`
---
---
---
Required SAS Components:
- Base SAS Software
---
---
Package contains additional content, run: `%loadPackageAddCnt(SQLinDS)` to load it
or look for the `sqlinds_AdditionalContent` directory in the `packages` fileref
localization (only if additional content was deployed during the installation process).
---------------------------------------------------------------------
*SAS package generated by SAS Package Framework, version `20251122`,*
*under `WIN`(`X64_10PRO`) operating system,*
*using SAS release: `9.04.01M9P06042025`.*
---------------------------------------------------------------------
# The `SQLinDS` package content
The `SQLinDS` package consists of the following content:
1. [`dssql` libname ](#dssql-libname-1 )
2. [`%dssql_inner()` macro ](#dssqlinner-macro-2 )
3. [`%sql()` macro ](#sql-macro-3 )
4. [`dssql()` function ](#dssql-function-4 )
5. [`sqlinds` kmfsnip ](#sqlinds-kmfsnip-5 )
6. [License note](#license)
---
## `dssql` libname <a name="dssql-libname-1"></a> ######
The `dsSQL` library stores temporary views
generated during the `%SQL()` macro execution.
If possible a sub-directory 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="dssqlinner-macro-2"></a> ######
The `%dsSQL_Inner()` macro is an **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.
The `%dsSQL_Inner()` is *not* designed to be
called on its own.
Recommended for *SAS 9.3* and higher.
---
---
## `%sql()` macro <a name="sql-macro-3"></a> ######
The `%SQL()` macro is the **main**
macro in the package. The macro allows
to use SQL queries in the data step.
Recommended for *SAS 9.3* and higher.
Implementation is 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)
Copy of the article can also be found in *additional content* directory.
### SYNTAX: ###################################################################
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%sql(<nonempty Proc SQL query code>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The THE query code is limited to approximately *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 name, age from sashelp.class
where sex = "F")(rename = (age=age2)
);
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3**: Proc SQL dictionaries in the data step
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data dictionary;
set %SQL(select dict.* from dictionary.macros as dict);
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
---
## `dssql()` function <a name="dssql-function-4"></a> ######
The `dsSQL()` function is an **internal**
function called by the `%SQL()` macro.
The function pass a query code from the `%SQL()`
macro to the `%dsSQL_Inner()` internal macro.
The `dsSQL()` is *not* designed to be
called on its own.
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.
---
---
## `sqlinds` kmfsnip <a name="sqlinds-kmfsnip-5"></a> ######
This is a help note for `sqlinds` KMF-abbreviation.
The snippet presents a template
for use of the `%SQL()` macro.
To read help info about the macro
run he following:
`%helpPackage(SQLinDS,'%sql()')`
---
---
# License <a name="license"></a> ######
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.
---

BIN
hist/2.3.1/sqlinds.zip Normal file

Binary file not shown.

View File

@@ -1,14 +1,30 @@
- [The SQLinDS package](#sqlinds-package) # Documentation for the `SQLinDS` package.
- [Content description](#content-description)
* [library `dsSQL`](#library-dssql) ----------------------------------------------------------------
* [`%dsSQL_inner()` macro](#dssql-inner-macro)
* [`%SQL()` macro](#dssql-inner-macro) *SQL queries in Data Step*
* [`dsSQL()` function](#dssql-function)
* [License](#license) ----------------------------------------------------------------
### Version information:
- Package: SQLinDS
- Version: 2.3.1
- Generated: 2025-11-22T12:47:32
- Author(s): Mike Rhoads (RhoadsM1@Westat.com), contributor Bartosz Jablonski
- Maintainer(s): Bartosz Jablonski (yabwon@gmail.com)
- License: MIT
- File SHA256: `F*606A24A2A6B06DAAD2D443FA9A9819D9564235A5CD8599FD15586F1EFFCB41BC` for this version
- Content SHA256: `C*4CCCF31DA9D94E0EE2DA612724D395056B7BA07CB593C93947835BB8319B33EB` for this version
--- ---
# The `SQLinDS` package, version: `2.3.1`;
---
# The SQLinDS package [ver. 2.3.0] <a name="sqlinds-package"></a> ############################################### ### The SQLinDS package [ver. 2.3.1]
The **SQLinDS** package is an implementation of The **SQLinDS** package is an implementation of
the *macro-function-sandwich* concept introduced in the the *macro-function-sandwich* concept introduced in the
@@ -20,13 +36,13 @@ The article is available at:
Copy of the article can also be found in *additional content* directory. Copy of the article can also be found in *additional content* directory.
Package provides ability to *execute* SQL queries inside a data step, e.g. Package provides ability to *execute* SQL queries inside a data step, e.g.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data class; data class;
set %SQL(select * from sashelp.class); set %SQL(select name, age from sashelp.class);
run; run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See the help for the `%SQL()` macro to find more examples. See the help for the `%SQL()` macro to find more examples.
### Content ################################################################### ### Content ###################################################################
@@ -41,67 +57,96 @@ SQLinDS package contains the following components:
--- ---
Package contains:
1. libname dssql
2. macro dssql_inner
3. macro sql
4. function dssql
5. kmfsnip sqlinds
Required SAS Components:
*Base SAS Software*
Package contains additional content, run: %loadPackageAddCnt(SQLinDS) to load it
or look for the sqlinds_AdditionalContent directory in the Packages fileref
localization (only if additional content was deployed during the installation process).
*SAS package generated by generatePackage, version 20231111*
The SHA256 hash digest for package SQLinDS:
`F*3C010734B76CA7459C4D35087C899121011CD4AA2932B56335FF11A805C8EF8D`
--- ---
# Content description ############################################################################################
---
## >>> library `dsSQL`: <<< <a name="library-dssql"></a> ########################
Required SAS Components:
- Base SAS Software
---
---
Package contains additional content, run: `%loadPackageAddCnt(SQLinDS)` to load it
or look for the `sqlinds_AdditionalContent` directory in the `packages` fileref
localization (only if additional content was deployed during the installation process).
---------------------------------------------------------------------
*SAS package generated by SAS Package Framework, version `20251122`,*
*under `WIN`(`X64_10PRO`) operating system,*
*using SAS release: `9.04.01M9P06042025`.*
---------------------------------------------------------------------
# The `SQLinDS` package content
The `SQLinDS` package consists of the following content:
1. [`dssql` libname ](#dssql-libname-1 )
2. [`%dssql_inner()` macro ](#dssqlinner-macro-2 )
3. [`%sql()` macro ](#sql-macro-3 )
4. [`dssql()` function ](#dssql-function-4 )
5. [`sqlinds` kmfsnip ](#sqlinds-kmfsnip-5 )
6. [License note](#license)
---
## `dssql` libname <a name="dssql-libname-1"></a> ######
The `dsSQL` library stores temporary views The `dsSQL` library stores temporary views
generated during the `%SQL()` macro execution. generated during the `%SQL()` macro execution.
If possible a subdirectory of the `WORK` location is created, like: If possible a sub-directory of the `WORK` location is created, like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp"; LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if not possible, then redirects to the `WORK` location, like: if not possible, then redirects to the `WORK` location, like:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))"; LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- ---
---
## `%dssql_inner()` macro <a name="dssqlinner-macro-2"></a> ######
The `%dsSQL_Inner()` macro is an **internal**
macro called by `dsSQL()` function.
## >>> `%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 The macro generates a uniquely named SQL view on the fly
which is then stored in the `dsSQL` library. which is then stored in the `dsSQL` library.
The `%dsSQL_Inner()` is *not* designed to be
called on its own.
Recommended for *SAS 9.3* and higher. Recommended for *SAS 9.3* and higher.
--- ---
---
## >>> `%SQL()` macro: <<< <a name="dssql-macro"></a> ###########################
## `%sql()` macro <a name="sql-macro-3"></a> ######
The **main** macro which allows to use
SQL queries in the data step. The `%SQL()` macro is the **main**
macro in the package. The macro allows
to use SQL queries in the data step.
Recommended for *SAS 9.3* and higher. Recommended for *SAS 9.3* and higher.
Based on the article *"Use the Full Power of SAS in Your Function-Style Macros"* Implementation is based on the article:
*"Use the Full Power of SAS in Your Function-Style Macros"*
by *Mike Rhoads* (Westat, Rockville), available at: 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) [https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
@@ -109,10 +154,10 @@ Copy of the article can also be found in *additional content* directory.
### SYNTAX: ################################################################### ### SYNTAX: ###################################################################
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%sql(<nonempty sql querry code>) %sql(<nonempty Proc SQL query code>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The sql query code is limited to *32000* bytes. The THE query code is limited to approximately *32000* bytes.
### EXAMPLES: ################################################################# ### EXAMPLES: #################################################################
@@ -126,26 +171,34 @@ run;
**EXAMPLE 2**: query with dataset options **EXAMPLE 2**: query with dataset options
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data renamed; data renamed;
set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2)); set %SQL(select name, age from sashelp.class
where sex = "F")(rename = (age=age2)
);
run; run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**EXAMPLE 3**: dictionaries in the data step **EXAMPLE 3**: Proc SQL dictionaries in the data step
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data dictionary; data dictionary;
set %SQL(select * from dictionary.macros); set %SQL(select dict.* from dictionary.macros as dict);
run; run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- ---
---
## >>> `dsSQL()` function: <<< <a name="dssql-function"></a> #################### ## `dssql()` function <a name="dssql-function-4"></a> ######
The `dsSQL()` function is an **internal**
function called by the `%SQL()` macro.
**Internal** function called by the `%SQL()` macro. The function pass a query code from the `%SQL()`
The function pass a query code from the `%SQL()`
macro to the `%dsSQL_Inner()` internal macro. macro to the `%dsSQL_Inner()` internal macro.
The `dsSQL()` is *not* designed to be
called on its own.
Recommended for *SAS 9.3* and higher. Recommended for *SAS 9.3* and higher.
### SYNTAX: ################################################################### ### SYNTAX: ###################################################################
@@ -161,8 +214,27 @@ dsSQL(unique_index_2, query)
--- ---
## License ####################################################################
---
## `sqlinds` kmfsnip <a name="sqlinds-kmfsnip-5"></a> ######
This is a help note for `sqlinds` KMF-abbreviation.
The snippet presents a template
for use of the `%SQL()` macro.
To read help info about the macro
run he following:
`%helpPackage(SQLinDS,'%sql()')`
---
---
# License <a name="license"></a> ######
Copyright (c) 2012 Mike Rhoads Copyright (c) 2012 Mike Rhoads
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -182,5 +254,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
--- ---

Binary file not shown.