Skip to content

Commit bb1cd6c

Browse files
committed
SQLinDS package [ver. 2.3.0]
SQLinDS package [ver. 2.3.0] - KMF snippet added - documentation updated
1 parent 49f21e8 commit bb1cd6c

5 files changed

Lines changed: 197 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The package allows to write SQL queries in the data step, e.g.
1010
set %SQL(select * from sashelp.class order by age);
1111
run;
1212
```
13-
SHA256 digest for the latest version of `SQLinDS`: F*42DC179E1D2B946AD519C4EC04A068061B312E021C3F4BC4826D2775E116E1B9
13+
SHA256 digest for the latest version of `SQLinDS`: F*3C010734B76CA7459C4D35087C899121011CD4AA2932B56335FF11A805C8EF8D
1414

1515
[**Documentation for SQLinDS**](./sqlinds.md "Documentation for SQLinDS")
1616

hist/2.3.0/sqlinds.md

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
- [The SQLinDS package](#sqlinds-package)
2+
- [Content description](#content-description)
3+
* [library `dsSQL`](#library-dssql)
4+
* [`%dsSQL_inner()` macro](#dssql-inner-macro)
5+
* [`%SQL()` macro](#dssql-inner-macro)
6+
* [`dsSQL()` function](#dssql-function)
7+
* [License](#license)
8+
9+
---
10+
11+
# The SQLinDS package [ver. 2.3.0] <a name="sqlinds-package"></a> ###############################################
12+
13+
The **SQLinDS** package is an implementation of
14+
the *macro-function-sandwich* concept introduced in the
15+
*"Use the Full Power of SAS in Your Function-Style Macros"*,
16+
the article by *Mike Rhoads (Westat, Rockville)*.
17+
18+
The article is available at:
19+
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
20+
21+
Copy of the article can also be found in *additional content* directory.
22+
23+
24+
Package provides ability to *execute* SQL queries inside a data step, e.g.
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
26+
data class;
27+
set %SQL(select * from sashelp.class);
28+
run;
29+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30+
See the help for the `%SQL()` macro to find more examples.
31+
32+
### Content ###################################################################
33+
34+
SQLinDS package contains the following components:
35+
36+
1. `%SQL()` macro - the main package macro available for the User
37+
2. `dsSQL()` function (internal)
38+
3. `%dsSQL_inner()` macro (internal)
39+
4. Library `DSSQL` (created as a subdirectory of the `WORK` library)
40+
5. Optional KMF-abbreviations `sqlinds`
41+
42+
---
43+
44+
Package contains:
45+
1. libname dssql
46+
2. macro dssql_inner
47+
3. macro sql
48+
4. function dssql
49+
5. kmfsnip sqlinds
50+
51+
Required SAS Components:
52+
*Base SAS Software*
53+
54+
Package contains additional content, run: %loadPackageAddCnt(SQLinDS) to load it
55+
or look for the sqlinds_AdditionalContent directory in the Packages fileref
56+
localization (only if additional content was deployed during the installation process).
57+
58+
*SAS package generated by generatePackage, version 20231111*
59+
60+
The SHA256 hash digest for package SQLinDS:
61+
`F*3C010734B76CA7459C4D35087C899121011CD4AA2932B56335FF11A805C8EF8D`
62+
63+
---
64+
# Content description ############################################################################################
65+
66+
67+
## >>> library `dsSQL`: <<< <a name="library-dssql"></a> ########################
68+
69+
The `dsSQL` library stores temporary views
70+
generated during the `%SQL()` macro execution.
71+
72+
If possible a subdirectory of the `WORK` location is created, like:
73+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
74+
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp";
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+
if not possible, then redirects to the `WORK` location, like:
78+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
79+
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))";
80+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81+
---
82+
83+
84+
85+
## >>> `%dsSQL_Inner()` macro: <<< <a name="dssql-inner-macro"></a> #############
86+
87+
**Internal** macro called by `dsSQL()` function.
88+
The macro generates a uniquely named SQL view on the fly
89+
which is then stored in the `dsSQL` library.
90+
91+
Recommended for *SAS 9.3* and higher.
92+
93+
---
94+
95+
96+
97+
## >>> `%SQL()` macro: <<< <a name="dssql-macro"></a> ###########################
98+
99+
The **main** macro which allows to use
100+
SQL queries in the data step.
101+
102+
Recommended for *SAS 9.3* and higher.
103+
104+
Based on the article *"Use the Full Power of SAS in Your Function-Style Macros"*
105+
by *Mike Rhoads* (Westat, Rockville), available at:
106+
[https://support.sas.com/resources/papers/proceedings12/004-2012.pdf](https://support.sas.com/resources/papers/proceedings12/004-2012.pdf)
107+
108+
Copy of the article can also be found in *additional content* directory.
109+
110+
### SYNTAX: ###################################################################
111+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
112+
%sql(<nonempty sql querry code>)
113+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114+
115+
The sql query code is limited to *32000* bytes.
116+
117+
### EXAMPLES: #################################################################
118+
119+
**EXAMPLE 1**: simple SQL query
120+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
121+
data class_subset;
122+
set %SQL(select name, sex, height from sashelp.class where age > 12);
123+
run;
124+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125+
126+
**EXAMPLE 2**: query with dataset options
127+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
128+
data renamed;
129+
set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2));
130+
run;
131+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132+
133+
**EXAMPLE 3**: dictionaries in the data step
134+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
135+
data dictionary;
136+
set %SQL(select * from dictionary.macros);
137+
run;
138+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+
---
140+
141+
142+
143+
## >>> `dsSQL()` function: <<< <a name="dssql-function"></a> ####################
144+
145+
**Internal** function called by the `%SQL()` macro.
146+
The function pass a query code from the `%SQL()`
147+
macro to the `%dsSQL_Inner()` internal macro.
148+
149+
Recommended for *SAS 9.3* and higher.
150+
151+
### SYNTAX: ###################################################################
152+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
153+
dsSQL(unique_index_2, query)
154+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155+
156+
**Arguments description**:
157+
158+
1. `unique_index_2` - *Numeric*, internal variable, a unique index for views.
159+
160+
2. `query` - *Character*, internal variable, contains query text.
161+
162+
---
163+
164+
## License ####################################################################
165+
166+
Copyright (c) 2012 Mike Rhoads
167+
168+
Permission is hereby granted, free of charge, to any person obtaining a copy
169+
of this software and associated documentation files (the "Software"), to deal
170+
in the Software without restriction, including without limitation the rights
171+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
172+
copies of the Software, and to permit persons to whom the Software is
173+
furnished to do so, subject to the following conditions:
174+
175+
The above copyright notice and this permission notice shall be included in all
176+
copies or substantial portions of the Software.
177+
178+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
179+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
180+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
181+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
182+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
183+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
184+
SOFTWARE.
185+
186+
---

hist/2.3.0/sqlinds.zip

195 KB
Binary file not shown.

sqlinds.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
---
1010

11-
# The SQLinDS package [ver. 2.2.7] <a name="sqlinds-package"></a> ###############################################
11+
# The SQLinDS package [ver. 2.3.0] <a name="sqlinds-package"></a> ###############################################
1212

1313
The **SQLinDS** package is an implementation of
1414
the *macro-function-sandwich* concept introduced in the
@@ -35,8 +35,9 @@ SQLinDS package contains the following components:
3535

3636
1. `%SQL()` macro - the main package macro available for the User
3737
2. `dsSQL()` function (internal)
38-
3. `%dsSQL_inner()` macro (internal)
38+
3. `%dsSQL_inner()` macro (internal)
3939
4. Library `DSSQL` (created as a subdirectory of the `WORK` library)
40+
5. Optional KMF-abbreviations `sqlinds`
4041

4142
---
4243

@@ -45,14 +46,19 @@ Package contains:
4546
2. macro dssql_inner
4647
3. macro sql
4748
4. function dssql
49+
5. kmfsnip sqlinds
4850

4951
Required SAS Components:
5052
*Base SAS Software*
5153

52-
*SAS package generated by generatePackage, version 20230905*
54+
Package contains additional content, run: %loadPackageAddCnt(SQLinDS) to load it
55+
or look for the sqlinds_AdditionalContent directory in the Packages fileref
56+
localization (only if additional content was deployed during the installation process).
57+
58+
*SAS package generated by generatePackage, version 20231111*
5359

5460
The SHA256 hash digest for package SQLinDS:
55-
`F*42DC179E1D2B946AD519C4EC04A068061B312E021C3F4BC4826D2775E116E1B9`
61+
`F*3C010734B76CA7459C4D35087C899121011CD4AA2932B56335FF11A805C8EF8D`
5662

5763
---
5864
# Content description ############################################################################################

sqlinds.zip

1.98 KB
Binary file not shown.

0 commit comments

Comments
 (0)