mirror of
https://github.com/yabwon/SAS_PACKAGES.git
synced 2026-01-09 07:50:06 +00:00
version 20200511
Help info added
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
/* >>> dsSQL library: <<<
|
||||
*
|
||||
* The dsSQL library stores temporary views
|
||||
* generated during %SQL() macro's execution.
|
||||
* If possible, created as a subdirectory of WORK:
|
||||
* generated during the %SQL() macro execution.
|
||||
* If possible a subdirectory of WORK is created as:
|
||||
|
||||
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))/dsSQLtmp";
|
||||
|
||||
* if not then redirected to WORK
|
||||
* if not possible then redirects to WORK as:
|
||||
|
||||
LIBNAME dsSQL BASE "%sysfunc(pathname(WORK))";
|
||||
|
||||
@@ -25,6 +25,5 @@ data _null_;
|
||||
rc1 = LIBNAME("dsSQL", "%sysfunc(pathname(work))", "BASE");
|
||||
run;
|
||||
|
||||
/* list details about the library in the log */
|
||||
libname dsSQL LIST;
|
||||
;
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/*** HELP START ***/
|
||||
/*** HELP START ***/
|
||||
|
||||
/* >>> %dsSQL_Inner() macro: <<<
|
||||
*
|
||||
* Internal macro called by dsSQL() function.
|
||||
* Internal macro called by dsSQL() function.
|
||||
* The macro generates a uniqualy named sql view on the fly
|
||||
* which is stored in DSSQL library.
|
||||
*
|
||||
* Recommended for SAS 9.3 and higher.
|
||||
* Based on paper:
|
||||
|
||||
@@ -10,13 +10,19 @@
|
||||
* by Mike Rhoads, Westat, Rockville, MD
|
||||
* https://support.sas.com/resources/papers/proceedings12/004-2012.pdf
|
||||
*
|
||||
* SYNTAX:
|
||||
|
||||
%sql(<nonempty sql querry code>)
|
||||
|
||||
* The sql querry code is limited to 32000 bytes.
|
||||
*
|
||||
* EXAMPLE 1: simple sql query
|
||||
|
||||
data class_subset;
|
||||
set %SQL(select name, sex, height from sashelp.class where age > 12);
|
||||
run;
|
||||
|
||||
* EXAMPLE 2: with dataset options
|
||||
* EXAMPLE 2: query with dataset options
|
||||
|
||||
data renamed;
|
||||
set %SQL(select * from sashelp.class where sex = "F")(rename = (age=age2));
|
||||
@@ -33,15 +39,15 @@
|
||||
/*** HELP END ***/
|
||||
|
||||
|
||||
/* outer macro */
|
||||
/* Main User macro */
|
||||
%MACRO SQL() / PARMBUFF SECURE;
|
||||
%let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */
|
||||
%let SYSPBUFF = %substr(&SYSPBUFF, 2, %LENGTH(&SYSPBUFF) - 2); /* remove brackets */
|
||||
%let SYSPBUFF = %superq(SYSPBUFF); /* macroquoting */
|
||||
%let SYSPBUFF = %sysfunc(quote(&SYSPBUFF)); /* quotes */
|
||||
%put NOTE-***the query***; /* print out the query in the log */
|
||||
%put NOTE:*** the query ***; /* print out the query in the log */
|
||||
%put NOTE-&SYSPBUFF.;
|
||||
%put NOTE-****************;
|
||||
%put NOTE-*****************;
|
||||
|
||||
%local UNIQUE_INDEX; /* internal variable, a unique index for views */
|
||||
%let UNIQUE_INDEX = &SYSINDEX;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/* >>> dsSQL() function: <<<
|
||||
*
|
||||
* Internal function called by %SQL() macro.
|
||||
* The function pass query code from the %SQL()
|
||||
* macro to the %dsSQL_Inner() innternal macreo.
|
||||
*
|
||||
* Recommended for SAS 9.3 and higher.
|
||||
* Based on paper:
|
||||
|
||||
@@ -23,14 +23,23 @@ the macro-function-sandwich concept introduced in:
|
||||
"Use the Full Power of SAS in Your Function-Style Macros"
|
||||
the article by Mike Rhoads, Westat, Rockville, MD
|
||||
|
||||
Copy of the article can be found at:
|
||||
Copy of the article is available at:
|
||||
https://support.sas.com/resources/papers/proceedings12/004-2012.pdf
|
||||
|
||||
SQLinDS package provides following components:
|
||||
1) %dsSQL_inner() macro
|
||||
2) dsSQL() function
|
||||
3) %SQL() macro
|
||||
Package provides ability to "execute" SQL queries inside a datastep, e.g.
|
||||
|
||||
Library DSSQL is created in a subdirectory of the WORK library.
|
||||
data class;
|
||||
set %SQL(select * from sashelp.class);
|
||||
run;
|
||||
|
||||
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 in a subdirectory of the WORK library)
|
||||
|
||||
See help for the %SQL() macro to find more examples.
|
||||
|
||||
DESCRIPTION END:
|
||||
|
||||
Reference in New Issue
Block a user